Merged in feature/testquery (pull request #39)
Test Query * depstextandclean * startedcleaningresult * resulttidyup * roundone * cleaning * unsyncedquery * startedtestsandsimplification * api * querytests * resultprocessortests * unittests * cleanup
This commit is contained in:
@@ -3,7 +3,7 @@ package controllers
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
documentsync "queryorchestration/internal/document/sync"
|
||||
"queryorchestration/internal/query"
|
||||
|
||||
"github.com/go-playground/validator/v10"
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
type Services struct {
|
||||
DocumentSync *documentsync.Service
|
||||
Query *query.Service
|
||||
}
|
||||
|
||||
type QueryRunner struct {
|
||||
@@ -32,7 +32,7 @@ type DocumentQueryEvent struct {
|
||||
}
|
||||
|
||||
func (s QueryRunner) Process(ctx context.Context, req *types.Message) error {
|
||||
var body documentsync.Document
|
||||
var body query.Document
|
||||
err := json.Unmarshal([]byte(*req.Body), &body)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -43,7 +43,7 @@ func (s QueryRunner) Process(ctx context.Context, req *types.Message) error {
|
||||
return err
|
||||
}
|
||||
|
||||
err = s.svc.DocumentSync.Sync(ctx, &body)
|
||||
err = s.svc.Query.Sync(ctx, &body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -6,15 +6,15 @@ import (
|
||||
controllers "queryorchestration/api/queryRunner"
|
||||
"queryorchestration/internal/database"
|
||||
"queryorchestration/internal/database/repository"
|
||||
documentsync "queryorchestration/internal/document/sync"
|
||||
documenttext "queryorchestration/internal/document/text"
|
||||
"queryorchestration/internal/job/collector"
|
||||
"queryorchestration/internal/query"
|
||||
"queryorchestration/internal/query/result"
|
||||
"testing"
|
||||
|
||||
"github.com/aws/aws-sdk-go-v2/service/sqs/types"
|
||||
"github.com/go-playground/validator/v10"
|
||||
"github.com/google/uuid"
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
"github.com/pashagolub/pgxmock/v3"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
@@ -32,18 +32,18 @@ func TestQueryRunner(t *testing.T) {
|
||||
Pool: pool,
|
||||
}
|
||||
|
||||
svc := documentsync.New(db, &documentsync.Services{
|
||||
Collector: collector.New(db, &collector.Services{
|
||||
Query: query.New(db),
|
||||
}),
|
||||
svc := query.New(db, &query.Services{
|
||||
Result: result.New(db),
|
||||
Text: documenttext.New(),
|
||||
Collector: collector.New(db, &collector.Services{}),
|
||||
})
|
||||
|
||||
runner := controllers.NewQueryRunner(validator.New(), &controllers.Services{
|
||||
DocumentSync: svc,
|
||||
Query: svc,
|
||||
})
|
||||
assert.NotNil(t, runner)
|
||||
|
||||
doc := documentsync.Document{
|
||||
doc := query.Document{
|
||||
ID: uuid.New(),
|
||||
JobID: uuid.New(),
|
||||
CleanVersion: 1,
|
||||
@@ -55,27 +55,10 @@ func TestQueryRunner(t *testing.T) {
|
||||
msg := &types.Message{
|
||||
Body: &body,
|
||||
}
|
||||
collectorID := database.MustToDBUUID(uuid.New())
|
||||
queryID := database.MustToDBUUID(uuid.New())
|
||||
minCleanVersion := int32(1)
|
||||
minTextVersion := int32(1)
|
||||
|
||||
qV := int32(1)
|
||||
|
||||
pool.ExpectQuery("name: GetCollectorByJobID :one").WithArgs(database.MustToDBUUID(doc.JobID)).
|
||||
pool.ExpectQuery("name: ListUnsyncedQueriesByDocId :many").WithArgs(database.MustToDBUUID(doc.ID)).
|
||||
WillReturnRows(
|
||||
pgxmock.NewRows([]string{"id", "jobId", "minCleanVersion", "minTextVersion", "activeVersion", "latestVersion", "fields"}).
|
||||
AddRow(collectorID, database.MustToDBUUID(doc.JobID), &minCleanVersion, &minTextVersion, int32(1), int32(2), []byte("")),
|
||||
)
|
||||
pool.ExpectQuery("name: ListResultsByDocumentID :many").WithArgs(database.MustToDBUUID(doc.ID), minCleanVersion, minTextVersion).
|
||||
WillReturnRows(
|
||||
pgxmock.NewRows([]string{"id", "queryId", "queryVersion"}).
|
||||
AddRow(collectorID, queryID, qV),
|
||||
)
|
||||
pool.ExpectQuery("name: ListCollectorQueries :many").WithArgs(collectorID).
|
||||
WillReturnRows(
|
||||
pgxmock.NewRows([]string{"collectorId", "queryId", "type", "queryVersion", "requiredIds"}).
|
||||
AddRow(collectorID, queryID, repository.QuerytypeContextFull, qV, []pgtype.UUID{}),
|
||||
pgxmock.NewRows([]string{"id", "type", "activeVersion", "latestVersion", "config", "requiredIds"}),
|
||||
)
|
||||
|
||||
err = runner.Process(ctx, msg)
|
||||
|
||||
Reference in New Issue
Block a user