2025-01-07 16:30:45 +00:00
|
|
|
package query_test
|
2025-01-06 14:40:43 +00:00
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"queryorchestration/internal/database"
|
|
|
|
|
"queryorchestration/internal/database/repository"
|
|
|
|
|
"queryorchestration/internal/query"
|
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
"github.com/google/uuid"
|
|
|
|
|
"github.com/pashagolub/pgxmock/v3"
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestTest(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 := query.New(db)
|
|
|
|
|
|
|
|
|
|
params := &query.Test{
|
|
|
|
|
QueryID: uuid.New(),
|
|
|
|
|
DocumentID: uuid.New(),
|
|
|
|
|
QueryVersion: int32(1),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result, err := svc.Test(ctx, *params)
|
|
|
|
|
assert.Nil(t, err)
|
|
|
|
|
assert.Empty(t, result)
|
|
|
|
|
}
|