diff options
Diffstat (limited to 'storage_test.go')
-rw-r--r-- | storage_test.go | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/storage_test.go b/storage_test.go index 5356596..32a10a6 100644 --- a/storage_test.go +++ b/storage_test.go @@ -94,16 +94,24 @@ func testFindOne(t *testing.T) { } } - - func TestBasicOperations(t *testing.T) { t.Run("testInsert", testInsert) t.Run("testFindOne", testFindOne) } func TestMain(m *testing.M) { + mongoHost, ok := os.LookupEnv("MONGO_HOST") + if !ok { + mongoHost = "localhost" + } + mongoPort, ok := os.LookupEnv("MONGO_PORT") + if !ok { + mongoHost = "27017" + } + uniqueDatabaseName := sha256.Sum256([]byte(time.Now().String())) - client, err := mongo.NewClient(options.Client().ApplyURI("mongodb://localhost:27017")) + + client, err := mongo.NewClient(options.Client().ApplyURI(fmt.Sprintf("mongodb://%s:%v", mongoHost, mongoPort))) if err != nil { panic("failed to create mongo client") } |