7ce7c9df4d
Feature/ecr * nosave * repo * awscli * unzip * ignore * moreram * 14k * ref * deployment * 12k * uselocal * go * dockercomd * reorder * iamgename * installs * tart * cli * clideps * y * dockerce * nodock * multi * rmecr * dev
57 lines
1.2 KiB
Go
57 lines
1.2 KiB
Go
package server_test
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"queryorchestration/internal/server"
|
|
"queryorchestration/internal/serviceconfig"
|
|
"queryorchestration/internal/test"
|
|
|
|
"github.com/go-playground/validator/v10"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestNewServer(t *testing.T) {
|
|
t.Parallel()
|
|
if testing.Short() {
|
|
t.SkipNow()
|
|
}
|
|
ctx := t.Context()
|
|
|
|
cfg := &server.BaseConfig{}
|
|
_ = serviceconfig.InitializeConfig(cfg)
|
|
|
|
test.CreateDBWithParams(t, cfg, &test.CreateDatabaseConfig{
|
|
NoMigrations: true,
|
|
})
|
|
|
|
clean, err := server.New(ctx, cfg)
|
|
require.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)
|
|
}
|
|
}()
|
|
}
|
|
|
|
func TestSetValidator(t *testing.T) {
|
|
cfg := server.BaseConfig{}
|
|
|
|
assert.Nil(t, cfg.Validator)
|
|
|
|
cfg.SetValidator()
|
|
assert.NotNil(t, cfg.Validator)
|
|
}
|
|
|
|
func TestGetValidator(t *testing.T) {
|
|
cfg := server.BaseConfig{}
|
|
|
|
assert.Nil(t, cfg.GetValidator())
|
|
cfg.Validator = validator.New()
|
|
assert.NotNil(t, cfg.GetValidator())
|
|
assert.EqualExportedValues(t, validator.New(), cfg.GetValidator())
|
|
}
|