forked from sourcegraph/sourcegraph-public-snapshot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ByTextReference accepts many references (sourcegraph#52247)
Part of [sourcegraph#52133](https://github.com/sourcegraph/sourcegraph/issues/52133) This pull request extends the Bag to take in many references at once. This is used for search (see sourcegraph#52219) where many ownership terms are given to include and exclude for search. ## Test plan Small test to verify a multi-bag works.
- Loading branch information
Showing
2 changed files
with
47 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -285,8 +285,33 @@ func TestBagUnverifiedEmailOnlyMatchesWithItself(t *testing.T) { | |
assert.True(t, bag.Contains(r), fmt.Sprintf("bag.Contains(%s), want true, got false", r)) | ||
} else { | ||
assert.False(t, bag.Contains(r), fmt.Sprintf("bag.Contains(%s), want false, got true", r)) | ||
|
||
} | ||
}) | ||
} | ||
} | ||
|
||
func TestBagManyUsers(t *testing.T) { | ||
if testing.Short() { | ||
t.Skip() | ||
} | ||
t.Parallel() | ||
logger := logtest.Scoped(t) | ||
db := edb.NewEnterpriseDB(database.NewDB(logger, dbtest.NewDB(logger, t))) | ||
ctx := context.Background() | ||
_, err := db.Users().Create(ctx, database.NewUser{ | ||
Email: "[email protected]", | ||
Username: "jdoe", | ||
EmailIsVerified: true, | ||
}) | ||
require.NoError(t, err) | ||
_, err = db.Users().Create(ctx, database.NewUser{ | ||
Email: "[email protected]", | ||
Username: "ssmith", | ||
EmailIsVerified: true, | ||
}) | ||
require.NoError(t, err) | ||
bag, err := ByTextReference(ctx, db, "jdoe", "ssmith") | ||
require.NoError(t, err) | ||
assert.True(t, bag.Contains(Reference{Handle: "ssmith"})) | ||
assert.True(t, bag.Contains(Reference{Handle: "jdoe"})) | ||
} |