From 8f9b4491f7816a0a02dc240f4784a64401b92e04 Mon Sep 17 00:00:00 2001 From: Jonathan Hall Date: Wed, 3 Jan 2024 16:13:14 +0100 Subject: [PATCH] Document current DBUpdates behavior --- couchdb/client_test.go | 21 +++++++++++++-------- updates.go | 3 +++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/couchdb/client_test.go b/couchdb/client_test.go index 50c7b2d66..5e532934c 100644 --- a/couchdb/client_test.go +++ b/couchdb/client_test.go @@ -245,10 +245,11 @@ func TestDestroyDB(t *testing.T) { func TestDBUpdates(t *testing.T) { tests := []struct { - name string - client *client - status int - err string + name string + client *client + options driver.Options + status int + err string }{ { name: "network error", @@ -280,10 +281,14 @@ func TestDBUpdates(t *testing.T) { }, nil), }, } - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - result, err := test.client.DBUpdates(context.TODO(), nil) - if d := internal.StatusErrorDiffRE(test.err, test.status, err); d != "" { + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + opts := tt.options + if opts == nil { + opts = mock.NilOption + } + result, err := tt.client.DBUpdates(context.TODO(), opts) + if d := internal.StatusErrorDiffRE(tt.err, tt.status, err); d != "" { t.Error(d) } if err != nil { diff --git a/updates.go b/updates.go index 37c797b8c..79b4d71d7 100644 --- a/updates.go +++ b/updates.go @@ -99,6 +99,9 @@ func (f *DBUpdates) Seq() string { // no more updates, when an error occurs, or when the [DBUpdates.Close] method // is called. The [DBUpdates.Err] method should be consulted to determine if // there was an error during iteration. +// +// For historical reasons, the CouchDB driver's implementation of this function +// always sets feed=continuous and since=now, and ignores any options passed. func (c *Client) DBUpdates(ctx context.Context, options ...Option) *DBUpdates { updater, ok := c.driverClient.(driver.DBUpdater) if !ok {