2025-01-10 11:12:03 +00:00
|
|
|
package server_test
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
2025-01-31 13:43:55 +00:00
|
|
|
"fmt"
|
2025-01-14 17:28:26 +00:00
|
|
|
"os"
|
|
|
|
|
"path"
|
2025-01-10 11:12:03 +00:00
|
|
|
"queryorchestration/internal/server"
|
2025-01-10 19:17:20 +00:00
|
|
|
"queryorchestration/internal/test"
|
2025-01-10 11:12:03 +00:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestNew(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 11:12:03 +00:00
|
|
|
ctx := context.Background()
|
|
|
|
|
|
2025-02-03 17:30:50 +00:00
|
|
|
sccfg := test.CreateBaseConfig()
|
|
|
|
|
sccfg.BasePath = path.Join(os.Getenv("PWD"), "../..")
|
|
|
|
|
cfg := &server.BaseConfig{
|
|
|
|
|
BaseConfig: *sccfg,
|
|
|
|
|
}
|
2025-01-10 11:12:03 +00:00
|
|
|
|
2025-01-31 13:43:55 +00:00
|
|
|
_, cleanup := test.CreateDB(t, ctx, &test.CreateDatabaseConfig{
|
|
|
|
|
Cfg: cfg,
|
|
|
|
|
})
|
|
|
|
|
defer cleanup()
|
2025-01-10 11:12:03 +00:00
|
|
|
|
2025-01-31 13:43:55 +00:00
|
|
|
clean, err := server.New(ctx, cfg)
|
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
defer func() {
|
|
|
|
|
if err := clean(); err != nil {
|
|
|
|
|
// Log cleanup error but don't panic since we're shutting down
|
|
|
|
|
fmt.Printf("Error during clean: %v", err)
|
|
|
|
|
}
|
|
|
|
|
}()
|
2025-01-10 11:12:03 +00:00
|
|
|
}
|