Merged in update/ci (pull request #127)
added CI * onlywherenecessary * export * dockersocketoverride * disablecleanup * networkfromenv * fullsuite * ci * dockerhost * name * network * buildfirst * rm * caches * additionalcaches * additionalcaches * cachenix * nix * requiredprofile * nonixcache * nobuild * moremem * rmgomodules * buildfirst * faster * clean
This commit is contained in:
@@ -3,6 +3,7 @@ package test
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
db "queryorchestration/internal/database"
|
||||
@@ -23,6 +24,8 @@ const (
|
||||
dbPort = 5432
|
||||
)
|
||||
|
||||
var dbLock sync.Mutex
|
||||
|
||||
func CreateDB(t testing.TB, cfg serviceconfig.ConfigProvider, network string, dcfg *CreateDatabaseConfig) testcontainers.Container {
|
||||
port, err := nat.NewPort("tcp", strconv.Itoa(dbPort))
|
||||
require.NoError(t, err)
|
||||
@@ -56,6 +59,8 @@ func CreateDB(t testing.TB, cfg serviceconfig.ConfigProvider, network string, dc
|
||||
},
|
||||
}
|
||||
|
||||
dbLock.Lock()
|
||||
|
||||
container, err := testcontainers.GenericContainer(t.Context(), testcontainers.GenericContainerRequest{
|
||||
ContainerRequest: req,
|
||||
Started: true,
|
||||
@@ -68,6 +73,8 @@ func CreateDB(t testing.TB, cfg serviceconfig.ConfigProvider, network string, dc
|
||||
mappedPort, err := container.MappedPort(t.Context(), port)
|
||||
require.NoError(t, err)
|
||||
|
||||
dbLock.Unlock()
|
||||
|
||||
cfg.SetDBHost(host)
|
||||
cfg.SetDBPort(mappedPort.Int())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user