diff --git a/db_test.go b/db_test.go index 557b02d24133ad623ef3b04d522c364cd3abcf28..045d363e94686924a4101968d4b1bae709ec41be 100644 --- a/db_test.go +++ b/db_test.go @@ -854,60 +854,64 @@ func TestFibonacci(t *testing.T) { t.Fatalf(`%s: Unexpected count %d.`, wrapper, total) } - // Find() with empty db.Cond. - res1 := col.Find(db.Cond{}) - total, err = res1.Count() + // Skipping mongodb as the results of this are not defined there. + if wrapper != `mongo` { - if total != 6 { - t.Fatalf(`%s: Unexpected count %d.`, wrapper, total) - } + // Find() with empty db.Cond. + res1 := col.Find(db.Cond{}) + total, err = res1.Count() - // Find() with empty expression - res1b := col.Find(db.Or{db.And{db.Cond{}, db.Cond{}}, db.Or{db.Cond{}}}) - total, err = res1b.Count() + if total != 6 { + t.Fatalf(`%s: Unexpected count %d.`, wrapper, total) + } - if total != 6 { - t.Fatalf(`%s: Unexpected count %d.`, wrapper, total) - } + // Find() with empty expression + res1b := col.Find(db.Or{db.And{db.Cond{}, db.Cond{}}, db.Or{db.Cond{}}}) + total, err = res1b.Count() - // Find() with explicit IS NULL - res2 := col.Find(db.Cond{"input IS": nil}) - total, err = res2.Count() + if total != 6 { + t.Fatalf(`%s: Unexpected count %d.`, wrapper, total) + } - if total != 0 { - t.Fatalf(`%s: Unexpected count %d.`, wrapper, total) - } + // Find() with explicit IS NULL + res2 := col.Find(db.Cond{"input IS": nil}) + total, err = res2.Count() - // Find() with implicit IS NULL - res2a := col.Find(db.Cond{"input": nil}) - total, err = res2a.Count() + if total != 0 { + t.Fatalf(`%s: Unexpected count %d.`, wrapper, total) + } - if total != 0 { - t.Fatalf(`%s: Unexpected count %d.`, wrapper, total) - } + // Find() with implicit IS NULL + res2a := col.Find(db.Cond{"input": nil}) + total, err = res2a.Count() - // Find() with explicit = NULL - res2b := col.Find(db.Cond{"input =": nil}) - total, err = res2b.Count() + if total != 0 { + t.Fatalf(`%s: Unexpected count %d.`, wrapper, total) + } - if total != 0 { - t.Fatalf(`%s: Unexpected count %d.`, wrapper, total) - } + // Find() with explicit = NULL + res2b := col.Find(db.Cond{"input =": nil}) + total, err = res2b.Count() - // Find() with implicit IN - res3 := col.Find(db.Cond{"input": []int{1, 2, 3, 4}}) - total, err = res3.Count() + if total != 0 { + t.Fatalf(`%s: Unexpected count %d.`, wrapper, total) + } - if total != 3 { - t.Fatalf(`%s: Unexpected count %d.`, wrapper, total) - } + // Find() with implicit IN + res3 := col.Find(db.Cond{"input": []int{1, 2, 3, 4}}) + total, err = res3.Count() + + if total != 3 { + t.Fatalf(`%s: Unexpected count %d.`, wrapper, total) + } - // Find() with implicit NOT IN - res3a := col.Find(db.Cond{"input NOT IN": []int{1, 2, 3, 4}}) - total, err = res3a.Count() + // Find() with implicit NOT IN + res3a := col.Find(db.Cond{"input NOT IN": []int{1, 2, 3, 4}}) + total, err = res3a.Count() - if total != 3 { - t.Fatalf(`%s: Unexpected count %d.`, wrapper, total) + if total != 3 { + t.Fatalf(`%s: Unexpected count %d.`, wrapper, total) + } } var items []fibonacci