bbe6f4188e
Feature/tests * improvetests * generation * simplifiedtesting * simplifiedtesting * longfile
56 lines
1.2 KiB
Go
56 lines
1.2 KiB
Go
package server_test
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"testing"
|
|
|
|
"queryorchestration/internal/server"
|
|
"queryorchestration/internal/test"
|
|
|
|
"github.com/go-playground/validator/v10"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestNewServer(t *testing.T) {
|
|
if testing.Short() {
|
|
t.Skip("Skipping long test in short mode")
|
|
}
|
|
ctx := context.Background()
|
|
|
|
cfg := &server.BaseConfig{}
|
|
test.SetCfgProvider(t, cfg)
|
|
net := test.DepNetwork.Get(t, ctx)
|
|
|
|
_ = test.CreateDB(t, ctx, cfg, net, &test.CreateDatabaseConfig{})
|
|
test.SetDBCfg(t, cfg)
|
|
|
|
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())
|
|
}
|