2025-01-10 19:17:20 +00:00
|
|
|
package test_test
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
2025-01-14 17:28:26 +00:00
|
|
|
"os"
|
|
|
|
|
"path"
|
2025-02-05 12:52:41 +00:00
|
|
|
"queryorchestration/internal/serviceconfig"
|
2025-01-10 19:17:20 +00:00
|
|
|
"queryorchestration/internal/test"
|
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestCreateDB(t *testing.T) {
|
2025-01-17 12:00:32 +00:00
|
|
|
if testing.Short() {
|
|
|
|
|
t.Skip("Skipping long test in short mode")
|
|
|
|
|
}
|
2025-01-10 19:17:20 +00:00
|
|
|
ctx := context.Background()
|
|
|
|
|
|
2025-02-05 12:52:41 +00:00
|
|
|
cfg := &serviceconfig.BaseConfig{}
|
|
|
|
|
test.SetCfgProvider(t, cfg)
|
|
|
|
|
cfg.SetBasePath(path.Join(os.Getenv("PWD"), "../.."))
|
2025-02-03 17:30:50 +00:00
|
|
|
|
2025-01-31 13:43:55 +00:00
|
|
|
dbcfg, cleanup := test.CreateDB(t, ctx, &test.CreateDatabaseConfig{Cfg: cfg})
|
2025-01-10 19:17:20 +00:00
|
|
|
assert.NotNil(t, dbcfg)
|
2025-02-05 12:52:41 +00:00
|
|
|
assert.Nil(t, cfg.GetDBPool())
|
2025-01-10 19:17:20 +00:00
|
|
|
assert.NotNil(t, cleanup)
|
|
|
|
|
|
|
|
|
|
cleanup()
|
|
|
|
|
}
|
2025-01-14 17:28:26 +00:00
|
|
|
|
|
|
|
|
func TestCreateDBWithMigrations(t *testing.T) {
|
2025-01-17 12:00:32 +00:00
|
|
|
if testing.Short() {
|
|
|
|
|
t.Skip("Skipping long test in short mode")
|
|
|
|
|
}
|
2025-01-14 17:28:26 +00:00
|
|
|
ctx := context.Background()
|
|
|
|
|
|
2025-02-05 12:52:41 +00:00
|
|
|
cfg := &serviceconfig.BaseConfig{}
|
|
|
|
|
test.SetCfgProvider(t, cfg)
|
|
|
|
|
cfg.SetBasePath(path.Join(os.Getenv("PWD"), "../.."))
|
2025-02-03 17:30:50 +00:00
|
|
|
|
2025-01-14 17:28:26 +00:00
|
|
|
dbcfg, cleanup := test.CreateDB(t, ctx, &test.CreateDatabaseConfig{
|
2025-01-31 13:43:55 +00:00
|
|
|
Cfg: cfg,
|
|
|
|
|
RunMigrations: true,
|
2025-01-14 17:28:26 +00:00
|
|
|
})
|
2025-01-31 13:43:55 +00:00
|
|
|
defer cleanup()
|
|
|
|
|
|
2025-01-14 17:28:26 +00:00
|
|
|
assert.NotNil(t, dbcfg)
|
2025-02-05 12:52:41 +00:00
|
|
|
assert.NotNil(t, cfg.GetDBPool())
|
2025-01-14 17:28:26 +00:00
|
|
|
assert.NotNil(t, cleanup)
|
|
|
|
|
}
|