mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-21 17:21:09 +01:00
26 lines
491 B
Go
26 lines
491 B
Go
package delegate_test
|
|
|
|
import (
|
|
"context"
|
|
"github.com/crawlab-team/crawlab/db/mongo"
|
|
"go.mongodb.org/mongo-driver/bson"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func SetupTest(t *testing.T) {
|
|
CleanupTest()
|
|
t.Cleanup(CleanupTest)
|
|
}
|
|
|
|
func CleanupTest() {
|
|
db := mongo.GetMongoDb("")
|
|
names, _ := db.ListCollectionNames(context.Background(), bson.M{})
|
|
for _, n := range names {
|
|
_, _ = db.Collection(n).DeleteMany(context.Background(), bson.M{})
|
|
}
|
|
|
|
// avoid caching
|
|
time.Sleep(200 * time.Millisecond)
|
|
}
|