From eab00f99b5fdfe20f75f4d36a028df1a388ae2ce Mon Sep 17 00:00:00 2001 From: Nikita Tokarchuk Date: Sun, 16 Jan 2022 22:56:44 +0100 Subject: [PATCH] Use hexed objectID as the name for ephemeral db name --- mongox-testing/database/ephemeral.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mongox-testing/database/ephemeral.go b/mongox-testing/database/ephemeral.go index 68a9d8d..eb6549d 100644 --- a/mongox-testing/database/ephemeral.go +++ b/mongox-testing/database/ephemeral.go @@ -2,9 +2,8 @@ package database import ( "context" - "math/rand" - "strconv" + "go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" @@ -20,7 +19,7 @@ type EphemeralDatabase struct { // NewEphemeral creates new mongo connection func NewEphemeral(URI string) (db *EphemeralDatabase, err error) { - name := strconv.Itoa(rand.Int()) + name := primitive.NewObjectID().Hex() opts := options.Client().ApplyURI(URI) client, err := mongo.Connect(context.Background(), opts)