Files
query-orchestration/internal/test/database_test.go
T

52 lines
1.1 KiB
Go
Raw Normal View History

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