Skip to content

Commit 96a4cca

Browse files
committed
add random db name if db container name was not set
1 parent 5eae99f commit 96a4cca

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

framework/components/postgres/postgres.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
"github.com/docker/docker/api/types/container"
1111
"github.com/docker/go-connections/nat"
12+
"github.com/google/uuid"
1213
"github.com/testcontainers/testcontainers-go"
1314
tcwait "github.com/testcontainers/testcontainers-go/wait"
1415

@@ -44,6 +45,9 @@ func NewPostgreSQL(in *Input) (*Output, error) {
4445
ctx := context.Background()
4546

4647
bindPort := fmt.Sprintf("%s/tcp", Port)
48+
if in.Name == "" {
49+
in.Name = uuid.NewString()[0:5]
50+
}
4751
containerName := framework.DefaultTCName(fmt.Sprintf("%s-%s", DBContainerLabel, in.Name))
4852

4953
var sqlCommands []string

0 commit comments

Comments
 (0)