fa95d733ca
Add short tests and Tidy internal directories * complete the tasks
45 lines
895 B
Go
45 lines
895 B
Go
package test_test
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"path"
|
|
"queryorchestration/internal/database"
|
|
"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()
|
|
|
|
dbcfg, cleanup := test.CreateDB(t, ctx, &test.CreateDatabaseConfig{})
|
|
assert.NotNil(t, dbcfg)
|
|
assert.Nil(t, dbcfg.Pool)
|
|
assert.NotNil(t, cleanup)
|
|
|
|
cleanup()
|
|
}
|
|
|
|
func TestCreateDBWithMigrations(t *testing.T) {
|
|
if testing.Short() {
|
|
t.Skip("Skipping long test in short mode")
|
|
}
|
|
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)
|
|
assert.NotNil(t, cleanup)
|
|
|
|
cleanup()
|
|
}
|