2025-01-10 19:17:20 +00:00
|
|
|
package test_test
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
2025-01-14 17:28:26 +00:00
|
|
|
"os"
|
|
|
|
|
"path"
|
2025-01-10 19:17:20 +00:00
|
|
|
"queryorchestration/internal/database"
|
|
|
|
|
"queryorchestration/internal/test"
|
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestCreateAPIContainer(t *testing.T) {
|
|
|
|
|
ctx := context.Background()
|
|
|
|
|
|
|
|
|
|
ncfg, ncleanup := test.CreateNetwork(t, ctx)
|
|
|
|
|
defer ncleanup()
|
|
|
|
|
dbcfg, dbcleanup := test.CreateDB(t, ctx, &test.CreateDatabaseConfig{
|
|
|
|
|
Network: ncfg,
|
|
|
|
|
Migrations: &database.MigrationConfig{
|
2025-01-14 17:28:26 +00:00
|
|
|
BasePath: path.Join(os.Getenv("PWD"), "../.."),
|
2025-01-10 19:17:20 +00:00
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
defer dbcleanup()
|
|
|
|
|
|
|
|
|
|
cfg := &test.APIContainerConfig{
|
|
|
|
|
ServiceName: "queryService",
|
|
|
|
|
DB: dbcfg.External,
|
|
|
|
|
Network: ncfg,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
conn, cleanup := test.CreateAPIContainer(t, ctx, cfg)
|
|
|
|
|
assert.NotNil(t, conn)
|
|
|
|
|
assert.NotNil(t, cleanup)
|
|
|
|
|
|
|
|
|
|
cleanup()
|
|
|
|
|
}
|
|
|
|
|
func TestCreateAPIWithDependencies(t *testing.T) {
|
|
|
|
|
ctx := context.Background()
|
|
|
|
|
|
|
|
|
|
conn, cleanup := test.CreateAPIWithDependencies(t, ctx, "queryService")
|
|
|
|
|
|
|
|
|
|
assert.NotNil(t, conn)
|
|
|
|
|
assert.NotNil(t, cleanup)
|
|
|
|
|
|
|
|
|
|
cleanup()
|
|
|
|
|
}
|