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

39 lines
755 B
Go
Raw Normal View History

package test_test
import (
"context"
2025-01-14 17:28:26 +00:00
"os"
"path"
"queryorchestration/internal/database"
"queryorchestration/internal/test"
"testing"
"github.com/stretchr/testify/assert"
)
func TestCreateDB(t *testing.T) {
ctx := context.Background()
dbcfg, cleanup := test.CreateDB(t, ctx, &test.CreateDatabaseConfig{})
assert.NotNil(t, dbcfg)
assert.Nil(t, dbcfg.Pool)
assert.NotNil(t, cleanup)
cleanup()
}
2025-01-14 17:28:26 +00:00
func TestCreateDBWithMigrations(t *testing.T) {
ctx := context.Background()
dbcfg, cleanup := test.CreateDB(t, ctx, &test.CreateDatabaseConfig{
Migrations: &database.MigrationConfig{
BasePath: path.Join(os.Getenv("PWD"), "../.."),
},
})
assert.NotNil(t, dbcfg)
assert.NotNil(t, dbcfg.Pool)
2025-01-14 17:28:26 +00:00
assert.NotNil(t, cleanup)
cleanup()
}