Skip to content

Commit

Permalink
docstore/mongodocstore: Make TestLowerCaseFields re-runnable (#3375)
Browse files Browse the repository at this point in the history
  • Loading branch information
vangent authored Dec 28, 2023
1 parent 6cd2499 commit 4d69f8c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions docstore/drivertest/driverbenchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
// RunBenchmarks runs benchmarks for docstore drivers.
func RunBenchmarks(b *testing.B, coll *docstore.Collection) {
defer coll.Close()
clearCollection(b, coll)
ClearCollection(b, coll)
b.Run("BenchmarkSingleActionPut", func(b *testing.B) {
benchmarkSingleActionPut(10, b, coll)
})
Expand All @@ -40,7 +40,7 @@ func RunBenchmarks(b *testing.B, coll *docstore.Collection) {
b.Run("BenchmarkActionListGet", func(b *testing.B) {
benchmarkActionListGet(100, b, coll)
})
clearCollection(b, coll)
ClearCollection(b, coll)
}

func benchmarkSingleActionPut(n int, b *testing.B, coll *docstore.Collection) {
Expand Down
6 changes: 3 additions & 3 deletions docstore/drivertest/drivertest.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ func withColl(t *testing.T, h Harness, kind CollectionKind, f func(*testing.T, H
}
coll := docstore.NewCollection(dc)
defer coll.Close()
clearCollection(t, coll)
ClearCollection(t, coll)
f(t, h, coll)
}

Expand Down Expand Up @@ -1541,8 +1541,8 @@ func filterHighScores(hs []*HighScore, f func(*HighScore) bool) []*HighScore {
return res
}

// clearCollection delete all documents from this collection after test.
func clearCollection(fataler interface{ Fatalf(string, ...interface{}) }, coll *docstore.Collection) {
// ClearCollection delete all documents from this collection after test.
func ClearCollection(fataler interface{ Fatalf(string, ...interface{}) }, coll *docstore.Collection) {
ctx := context.Background()
iter := coll.Query().Get(ctx)
dels := coll.Actions()
Expand Down
1 change: 1 addition & 0 deletions docstore/mongodocstore/mongo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ func TestLowercaseFields(t *testing.T) {
}
coll := docstore.NewCollection(dc)
defer coll.Close()
defer drivertest.ClearCollection(t, coll)

type S struct {
ID, F, G int
Expand Down

0 comments on commit 4d69f8c

Please sign in to comment.