Merged in feature/functestcov (pull request #84)

Function Test Coverage

* test

* scripts
This commit is contained in:
Michael McGuinness
2025-03-04 15:51:03 +00:00
parent 4b8c930ff1
commit d91ef1832b
85 changed files with 446 additions and 489 deletions
+8 -21
View File
@@ -10,6 +10,7 @@ import (
"time"
"github.com/docker/go-connections/nat"
"github.com/stretchr/testify/require"
"github.com/testcontainers/testcontainers-go"
"github.com/testcontainers/testcontainers-go/wait"
)
@@ -24,9 +25,7 @@ func CreateDB(t testing.TB, ctx context.Context, cfg *CreateDatabaseConfig) (tes
alias := "postgres"
port, err := nat.NewPort("tcp", "5432")
if err != nil {
t.Fatalf("Failed to create port: %v", err)
}
require.NoError(t, err)
name := "queryorchestration"
pass := "pass"
@@ -64,18 +63,12 @@ func CreateDB(t testing.TB, ctx context.Context, cfg *CreateDatabaseConfig) (tes
ContainerRequest: req,
Started: true,
})
if err != nil {
t.Fatalf("Failed to start container: %v", err)
}
require.NoError(t, err)
host, err := container.Host(ctx)
if err != nil {
t.Fatalf("Failed to extract host: %v", err)
}
require.NoError(t, err)
mappedPort, err := container.MappedPort(ctx, port)
if err != nil {
t.Fatalf("Failed to extract port: %v", err)
}
require.NoError(t, err)
dbcfg := &database.DBConfig{
DBName: name,
@@ -101,14 +94,10 @@ func CreateDB(t testing.TB, ctx context.Context, cfg *CreateDatabaseConfig) (tes
if cfg.RunMigrations {
err := migrations.Run(ctx, cfg.Cfg)
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)
err = cfg.Cfg.SetDBPool(ctx)
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)
}
if cfg.Network != nil {
@@ -119,8 +108,6 @@ func CreateDB(t testing.TB, ctx context.Context, cfg *CreateDatabaseConfig) (tes
return container, func() {
err := container.Terminate(ctx)
if err != nil {
t.Error(err)
}
require.NoError(t, err)
}
}