Skip to content

Commit

Permalink
Fix panic assigning to nil map
Browse files Browse the repository at this point in the history
  • Loading branch information
flimzy committed Dec 4, 2024
1 parent 0c1bf3f commit bdb0600
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion couchdb/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
)

func (c *client) AllDBs(ctx context.Context, opts driver.Options) ([]string, error) {
var query url.Values
query := url.Values{}
opts.Apply(&query)
var allDBs []string
err := c.DoJSON(ctx, http.MethodGet, "/_all_dbs", &chttp.Options{Query: query}, &allDBs)
Expand Down
6 changes: 6 additions & 0 deletions couchdb/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ func TestAllDBs(t *testing.T) {
}, nil),
expected: []string{"_global_changes", "_replicator", "_users"},
})
tests.Add("with param", test{
client: newTestClient(nil, errors.New("expected")),
options: kivik.Param("startkey", "bar"),
status: http.StatusBadGateway,
err: `Get "?http://example.com/_all_dbs\?startkey=bar"?: expected`,
})

tests.Run(t, func(t *testing.T, test test) {
opts := test.options
Expand Down

0 comments on commit bdb0600

Please sign in to comment.