2025-01-10 19:17:20 +00:00
|
|
|
package test
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
2025-01-15 12:19:49 +00:00
|
|
|
"os"
|
|
|
|
|
"path"
|
|
|
|
|
"queryorchestration/internal/database"
|
2025-01-10 19:17:20 +00:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestCreateQueueContainer(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()
|
|
|
|
|
|
|
|
|
|
ncfg, ncleanup := CreateNetwork(t, ctx)
|
|
|
|
|
defer ncleanup()
|
|
|
|
|
dbcfg, dbcleanup := CreateDB(t, ctx, &CreateDatabaseConfig{
|
2025-01-15 12:19:49 +00:00
|
|
|
Migrations: &database.MigrationConfig{
|
|
|
|
|
BasePath: path.Join(os.Getenv("PWD"), "../.."),
|
|
|
|
|
},
|
2025-01-10 19:17:20 +00:00
|
|
|
Network: ncfg,
|
|
|
|
|
})
|
|
|
|
|
defer dbcleanup()
|
|
|
|
|
qcfg, qcleanup := CreateQueue(t, ctx, &CreateQueueConfig{
|
|
|
|
|
Network: ncfg,
|
|
|
|
|
})
|
|
|
|
|
defer qcleanup()
|
|
|
|
|
|
|
|
|
|
extcfg := &queueConfig{
|
|
|
|
|
URL: qcfg.URL,
|
|
|
|
|
Region: qcfg.External.Region,
|
|
|
|
|
Endpoint: qcfg.External.Endpoint,
|
|
|
|
|
Credentials: qcfg.External.Credentials,
|
|
|
|
|
}
|
|
|
|
|
cfg := &QueueContainerConfig{
|
|
|
|
|
ServiceName: "queryRunner",
|
|
|
|
|
DB: dbcfg.External,
|
|
|
|
|
Network: ncfg,
|
|
|
|
|
Queue: extcfg,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cleanup := CreateQueueContainer(t, ctx, cfg)
|
|
|
|
|
assert.NotNil(t, cleanup)
|
|
|
|
|
|
|
|
|
|
cleanup()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestCreateQueueWithDependencies(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()
|
|
|
|
|
|
|
|
|
|
conn, cleanup := CreateQueueWithDependencies(t, ctx, "queryRunner")
|
|
|
|
|
|
|
|
|
|
assert.NotNil(t, conn)
|
|
|
|
|
assert.NotNil(t, cleanup)
|
|
|
|
|
|
|
|
|
|
cleanup()
|
|
|
|
|
}
|