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

add rand number to database name

parent 5f9dfeba
......@@ -5,6 +5,7 @@ import (
"database/sql"
"fmt"
"io/fs"
"math/rand"
"os"
"path/filepath"
"testing"
......@@ -100,8 +101,8 @@ func setupTestDatabase(t *testing.T) string {
require.NoError(t, err)
require.NoError(t, pg.Ping())
// create database
dbName := fmt.Sprintf("indexer_test_%d", time.Now().Unix())
// 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_%d", rand.Intn(10_000), time.Now().UnixNano())
_, err = pg.Exec("CREATE DATABASE " + dbName)
require.NoError(t, err)
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