Skip to content

Commit

Permalink
test(firestore): fix order by in integration test (#3227)
Browse files Browse the repository at this point in the history
  • Loading branch information
tbpg committed Nov 18, 2020
1 parent 99f7212 commit 758a88d
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions firestore/integration_test.go
Expand Up @@ -644,28 +644,32 @@ func TestIntegration_QueryDocuments(t *testing.T) {
h.mustCreate(doc, map[string]interface{}{"q": i, "x": 1})
wants = append(wants, map[string]interface{}{"q": int64(i)})
}
q := coll.Select("q").OrderBy("q", Asc)
q := coll.Select("q")
for i, test := range []struct {
q Query
want []map[string]interface{}
q Query
want []map[string]interface{}
orderBy bool // Some query types do not allow ordering.
}{
{q, wants},
{q.Where("q", ">", 1), wants[2:]},
{q.Where("q", "<", 1), wants[:1]},
{q.Where("q", "==", 1), wants[1:2]},
{q.Where("q", "!=", 0), wants[1:]},
{q.Where("q", ">=", 1), wants[1:]},
{q.Where("q", "<=", 1), wants[:2]},
{q.Where("q", "in", []int{0, 1}), wants[:2]},
{q.Where("q", "not-in", []int{0, 1}), wants[2:]},
{q.WherePath([]string{"q"}, ">", 1), wants[2:]},
{q.Offset(1).Limit(1), wants[1:2]},
{q.StartAt(1), wants[1:]},
{q.StartAfter(1), wants[2:]},
{q.EndAt(1), wants[:2]},
{q.EndBefore(1), wants[:1]},
{q.LimitToLast(2), wants[1:]},
{q, wants, true},
{q.Where("q", ">", 1), wants[2:], true},
{q.Where("q", "<", 1), wants[:1], true},
{q.Where("q", "==", 1), wants[1:2], false},
{q.Where("q", "!=", 0), wants[1:], true},
{q.Where("q", ">=", 1), wants[1:], true},
{q.Where("q", "<=", 1), wants[:2], true},
{q.Where("q", "in", []int{0}), wants[:1], false},
{q.Where("q", "not-in", []int{0, 1}), wants[2:], true},
{q.WherePath([]string{"q"}, ">", 1), wants[2:], true},
{q.Offset(1).Limit(1), wants[1:2], true},
{q.StartAt(1), wants[1:], true},
{q.StartAfter(1), wants[2:], true},
{q.EndAt(1), wants[:2], true},
{q.EndBefore(1), wants[:1], true},
{q.LimitToLast(2), wants[1:], true},
} {
if test.orderBy {
test.q = test.q.OrderBy("q", Asc)
}
gotDocs, err := test.q.Documents(ctx).GetAll()
if err != nil {
t.Errorf("#%d: %+v: %v", i, test.q, err)
Expand Down

1 comment on commit 758a88d

@jacksgt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks for the fix!

Please sign in to comment.