feat: Backend api for filtering users using filter query string (#2553)

* User search query string
This commit is contained in:
Steven Masley
2022-06-24 10:02:23 -05:00
committed by GitHub
parent 981fb2764f
commit d21ab2115d
13 changed files with 344 additions and 85 deletions
+29
View File
@@ -21,6 +21,35 @@ func TestContains(t *testing.T) {
)
}
func TestOverlap(t *testing.T) {
t.Parallel()
assertSetOverlaps(t, true, []int{1, 2, 3, 4, 5}, []int{1, 2, 3, 4, 5})
assertSetOverlaps(t, true, []int{10}, []int{10})
assertSetOverlaps(t, false, []int{1, 2, 3, 4, 5}, []int{6, 7, 8, 9})
assertSetOverlaps(t, false, []int{1, 2, 3, 4, 5}, []int{})
assertSetOverlaps(t, false, []int{}, []int{})
assertSetOverlaps(t, true, []string{"hello", "world", "foo", "bar", "baz"}, []string{"hello", "world", "baz"})
assertSetOverlaps(t, true,
[]uuid.UUID{uuid.New(), uuid.MustParse("c7c6686d-a93c-4df2-bef9-5f837e9a33d5"), uuid.MustParse("8f3b3e0b-2c3f-46a5-a365-fd5b62bd8818")},
[]uuid.UUID{uuid.MustParse("c7c6686d-a93c-4df2-bef9-5f837e9a33d5")},
)
}
func assertSetOverlaps[T comparable](t *testing.T, overlap bool, a []T, b []T) {
t.Helper()
for _, e := range a {
require.True(t, slice.Overlap(a, []T{e}), "elements in set should overlap with itself")
}
for _, e := range b {
require.True(t, slice.Overlap(b, []T{e}), "elements in set should overlap with itself")
}
require.Equal(t, overlap, slice.Overlap(a, b))
}
func assertSetContains[T comparable](t *testing.T, set []T, in []T, out []T) {
t.Helper()
for _, e := range set {