49 lines
1.1 KiB
Go
49 lines
1.1 KiB
Go
package document_test
|
|
|
|
import (
|
|
"context"
|
|
"queryorchestration/internal/database"
|
|
"queryorchestration/internal/database/repository"
|
|
jsonextractor "queryorchestration/internal/jsonExtractor"
|
|
queryprocessor "queryorchestration/internal/queryProcessor"
|
|
"testing"
|
|
|
|
"github.com/google/uuid"
|
|
"github.com/pashagolub/pgxmock/v3"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestUpdatorValidate(t *testing.T) {
|
|
ctx := context.Background()
|
|
|
|
pool, err := pgxmock.NewPool()
|
|
if err != nil {
|
|
t.Fatalf("failed to open pgxmock database: %v", err)
|
|
}
|
|
queries := repository.New(pool)
|
|
db := &database.Connection{
|
|
Queries: queries,
|
|
Pool: pool,
|
|
}
|
|
|
|
svc := jsonextractor.NewUpdator(db)
|
|
assert.NotNil(t, svc)
|
|
|
|
current := &queryprocessor.Query{
|
|
ID: uuid.New(),
|
|
Type: queryprocessor.TypeJsonExtractor,
|
|
Version: int32(1),
|
|
RequiredQueryIDs: []uuid.UUID{},
|
|
Config: "",
|
|
}
|
|
|
|
entity := &queryprocessor.Update{
|
|
ID: current.ID,
|
|
RequiredQueryIDs: []uuid.UUID{},
|
|
Config: "",
|
|
}
|
|
|
|
err = svc.Validate(ctx, current, entity)
|
|
assert.Nil(t, err)
|
|
}
|