From eaad13ce38d57daf149c14c774fae29ca3eda035 Mon Sep 17 00:00:00 2001 From: Robert van Gent <rvangent@google.com> Date: Thu, 28 Dec 2023 07:41:08 +0000 Subject: [PATCH] docstore/mongodocstore: Make TestLowerCaseFields re-runnable --- docstore/mongodocstore/mongo_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docstore/mongodocstore/mongo_test.go b/docstore/mongodocstore/mongo_test.go index 2e29e1d21e..d7d038dddd 100644 --- a/docstore/mongodocstore/mongo_test.go +++ b/docstore/mongodocstore/mongo_test.go @@ -21,6 +21,7 @@ import ( "context" "errors" "fmt" + "io" "testing" "time" @@ -236,6 +237,25 @@ func TestLowercaseFields(t *testing.T) { } coll := docstore.NewCollection(dc) defer coll.Close() + defer func() { + // Delete all items in the collection. + iter := coll.Query().Get(ctx) + dels := coll.Actions() + for { + doc := map[string]interface{}{} + err := iter.Next(ctx, doc) + if err == io.EOF { + break + } + if err != nil { + t.Fatalf("%+v", err) + } + dels.Delete(doc) + } + if err := dels.Do(ctx); err != nil { + t.Fatalf("%+v", err) + } + }() type S struct { ID, F, G int