-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #239 from go-kivik/release3.1
Prepare for release of 3.1
- Loading branch information
Showing
22 changed files
with
849 additions
and
65 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
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
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 |
---|---|---|
@@ -0,0 +1,143 @@ | ||
package couchdb_test | ||
|
||
import ( | ||
"context" | ||
"os" | ||
"testing" | ||
|
||
"gitlab.com/flimzy/testy" | ||
|
||
kivik "github.com/go-kivik/kivik/v3" | ||
) | ||
|
||
func TestQueries_1_x(t *testing.T) { | ||
dsn := os.Getenv("KIVIK_TEST_DSN_COUCH17") | ||
if dsn == "" { | ||
t.Skip("KIVIK_TEST_DSN_COUCH17 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) | ||
} | ||
} | ||
|
||
func TestQueries_2_x(t *testing.T) { | ||
dsn := os.Getenv("KIVIK_TEST_DSN_COUCH23") | ||
if dsn == "" { | ||
dsn = os.Getenv("KIVIK_TEST_DSN_COUCH22") | ||
} | ||
if dsn == "" { | ||
t.Skip("Neither KIVIK_TEST_DSN_COUCH22 nor KIVIK_TEST_DSN_COUCH23 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) | ||
} | ||
} | ||
|
||
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) | ||
} | ||
} |
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
Oops, something went wrong.