Skip to content

Commit

Permalink
Run multi-query test against CouchDB 3.x too
Browse files Browse the repository at this point in the history
  • Loading branch information
flimzy committed May 2, 2020
1 parent b0a1306 commit 8957001
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 6 deletions.
48 changes: 42 additions & 6 deletions db_live_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,45 @@ func TestQueries_2_x(t *testing.T) {
}
}

// func TestQueries_3_x(t *testing.T) {
// dsn := os.Getenv("KIVIK_TEST_DSN_COUCH30")
// if dsn == "" {
// t.Skip("KIVIK_TEST_DSN_COUCH30 not configured")
// }
// }
func TestQueries_3_x(t *testing.T) {
dsn := os.Getenv("KIVIK_TEST_DSN_COUCH30")
if dsn == "" {
t.Skip("KIVIK_TEST_DSN_COUCH30 not configured")
}

client, err := kivik.New("couch", dsn)
if err != nil {
t.Fatal(err)
}

db := client.DB(context.Background(), "_users")
rows, err := db.AllDocs(context.Background(), map[string]interface{}{
"queries": []map[string]interface{}{
{},
{},
},
})
if err != nil {
t.Fatal(err)
}
defer rows.Close() // nolint:errcheck
result := make([]interface{}, 0)
for rows.Next() {
if rows.EOQ() {
result = append(result, map[string]interface{}{
"EOQ": true,
"total_rows": rows.TotalRows(),
})
continue
}
result = append(result, map[string]interface{}{
"_id": rows.ID(),
})
}
if err := rows.Err(); err != nil {
t.Fatal(err)
}
if d := testy.DiffInterface(testy.Snapshot(t), result); d != nil {
t.Error(d)
}
}
16 changes: 16 additions & 0 deletions testdata/TestQueries_3_x
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
([]interface {}) (len=4) {
(map[string]interface {}) (len=1) {
(string) (len=3) "_id": (string) (len=13) "_design/_auth"
},
(map[string]interface {}) (len=2) {
(string) (len=3) "EOQ": (bool) true,
(string) (len=10) "total_rows": (int64) 1
},
(map[string]interface {}) (len=1) {
(string) (len=3) "_id": (string) (len=13) "_design/_auth"
},
(map[string]interface {}) (len=2) {
(string) (len=3) "EOQ": (bool) true,
(string) (len=10) "total_rows": (int64) 1
}
}

0 comments on commit 8957001

Please sign in to comment.