Commit 1fd2a70a authored by Hamdi Allam's avatar Hamdi Allam

add rand number to database name

parent 5f9dfeba
...@@ -5,6 +5,7 @@ import ( ...@@ -5,6 +5,7 @@ import (
"database/sql" "database/sql"
"fmt" "fmt"
"io/fs" "io/fs"
"math/rand"
"os" "os"
"path/filepath" "path/filepath"
"testing" "testing"
...@@ -100,8 +101,8 @@ func setupTestDatabase(t *testing.T) string { ...@@ -100,8 +101,8 @@ func setupTestDatabase(t *testing.T) string {
require.NoError(t, err) require.NoError(t, err)
require.NoError(t, pg.Ping()) require.NoError(t, pg.Ping())
// create database // create database. In the rare case two tests are run at the same nanosecond, we add a random number to the name
dbName := fmt.Sprintf("indexer_test_%d", time.Now().Unix()) dbName := fmt.Sprintf("indexer_test_%d_%d", rand.Intn(10_000), time.Now().UnixNano())
_, err = pg.Exec("CREATE DATABASE " + dbName) _, err = pg.Exec("CREATE DATABASE " + dbName)
require.NoError(t, err) require.NoError(t, err)
t.Cleanup(func() { t.Cleanup(func() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment