Merged in feature/textextract (pull request #108)
Start adding Textract + UUID changes * base * startclient * ts * short * tests
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"queryorchestration/internal/database"
|
||||
"queryorchestration/internal/database/repository"
|
||||
resultsync "queryorchestration/internal/query/result/sync"
|
||||
"queryorchestration/internal/serviceconfig"
|
||||
@@ -44,28 +43,26 @@ func TestSync(t *testing.T) {
|
||||
|
||||
t.Run("valid", func(t *testing.T) {
|
||||
id := uuid.New()
|
||||
qs := []uuid.UUID{
|
||||
uuid.New(),
|
||||
uuid.New(),
|
||||
}
|
||||
reqOne := uuid.New()
|
||||
reqTwo := uuid.New()
|
||||
|
||||
pool.ExpectQuery("name: IsDocumentTextExtracted :one").WithArgs(database.MustToDBUUID(id)).
|
||||
pool.ExpectQuery("name: IsDocumentTextExtracted :one").WithArgs(id).
|
||||
WillReturnRows(
|
||||
pgxmock.NewRows([]string{"isextracted"}).
|
||||
AddRow(true),
|
||||
)
|
||||
pool.ExpectQuery("name: ListUnsyncedNoDepsQueriesByDocId :many").WithArgs(database.MustToDBUUID(id)).
|
||||
pool.ExpectQuery("name: ListUnsyncedNoDepsQueriesByDocId :many").WithArgs(&id).
|
||||
WillReturnRows(
|
||||
pgxmock.NewRows([]string{"id"}).
|
||||
AddRow(database.MustToDBUUID(qs[0])).
|
||||
AddRow(database.MustToDBUUID(qs[1])),
|
||||
AddRow(&reqOne).
|
||||
AddRow(&reqTwo),
|
||||
)
|
||||
|
||||
mockSQS.EXPECT().
|
||||
SendMessage(
|
||||
mock.Anything,
|
||||
mock.MatchedBy(func(in *sqs.SendMessageInput) bool {
|
||||
return *in.QueueUrl == cfg.QueryURL && *in.MessageBody == fmt.Sprintf("{\"document_id\":\"%s\",\"query_id\":\"%s\"}", id.String(), qs[0].String())
|
||||
return *in.QueueUrl == cfg.QueryURL && *in.MessageBody == fmt.Sprintf("{\"document_id\":\"%s\",\"query_id\":\"%s\"}", id.String(), reqOne.String())
|
||||
}),
|
||||
mock.Anything,
|
||||
).
|
||||
@@ -75,7 +72,7 @@ func TestSync(t *testing.T) {
|
||||
SendMessage(
|
||||
mock.Anything,
|
||||
mock.MatchedBy(func(in *sqs.SendMessageInput) bool {
|
||||
return *in.QueueUrl == cfg.QueryURL && *in.MessageBody == fmt.Sprintf("{\"document_id\":\"%s\",\"query_id\":\"%s\"}", id.String(), qs[1].String())
|
||||
return *in.QueueUrl == cfg.QueryURL && *in.MessageBody == fmt.Sprintf("{\"document_id\":\"%s\",\"query_id\":\"%s\"}", id.String(), reqTwo.String())
|
||||
}),
|
||||
mock.Anything,
|
||||
).
|
||||
@@ -86,7 +83,7 @@ func TestSync(t *testing.T) {
|
||||
t.Run("not extracted", func(t *testing.T) {
|
||||
id := uuid.New()
|
||||
|
||||
pool.ExpectQuery("name: IsDocumentTextExtracted :one").WithArgs(database.MustToDBUUID(id)).
|
||||
pool.ExpectQuery("name: IsDocumentTextExtracted :one").WithArgs(id).
|
||||
WillReturnRows(
|
||||
pgxmock.NewRows([]string{"isextracted"}).
|
||||
AddRow(false),
|
||||
|
||||
Reference in New Issue
Block a user