Merged in feature/removejob (pull request #95)

Remove Job

* removejob

* rmjob

* sync

* cleanup

* precommit

* startslow

* startslow

* startslow

* openapi

* clean

* test

* scripts

* littlecleanercmds

* mermaid
This commit is contained in:
Michael McGuinness
2025-03-10 11:03:00 +00:00
parent 7d78e65d0c
commit 62886dbba8
148 changed files with 2088 additions and 3828 deletions
+24 -15
View File
@@ -3,6 +3,7 @@ package docsyncrunner_test
import (
"context"
"encoding/json"
"fmt"
"testing"
docsyncrunner "queryorchestration/api/docSyncRunner"
@@ -11,15 +12,17 @@ import (
"queryorchestration/internal/database/repository"
"queryorchestration/internal/document"
documentsync "queryorchestration/internal/document/sync"
"queryorchestration/internal/job"
"queryorchestration/internal/serviceconfig"
"queryorchestration/internal/serviceconfig/queue/documentclean"
queuemock "queryorchestration/mocks/queue"
"github.com/aws/aws-sdk-go-v2/service/sqs"
"github.com/aws/aws-sdk-go-v2/service/sqs/types"
"github.com/go-playground/validator/v10"
"github.com/google/uuid"
"github.com/pashagolub/pgxmock/v3"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
)
@@ -37,24 +40,24 @@ func TestDocInitRunner(t *testing.T) {
cfg := &DocSyncConfig{}
cfg.DBPool = pool
cfg.DBQueries = repository.New(pool)
mockSQS := queuemock.NewMockSQSClient(t)
cfg.QueueClient = mockSQS
runner := docsyncrunner.New(validator.New(), &docsyncrunner.Services{
Document: documentsync.New(cfg, &documentsync.Services{
Document: document.New(cfg),
Job: job.New(cfg, &job.Services{
Client: client.New(cfg),
}),
Client: client.New(cfg, &client.Services{}),
}),
})
assert.NotNil(t, runner)
t.Run("valid", func(t *testing.T) {
j := job.Job{
j := client.Client{
ID: uuid.New(),
}
docinfo := document.Document{
ID: uuid.New(),
JobID: j.ID,
ID: uuid.New(),
ClientID: j.ID,
}
doc := docsyncrunner.Body{
ID: docinfo.ID,
@@ -68,19 +71,25 @@ func TestDocInitRunner(t *testing.T) {
pool.ExpectQuery("name: GetDocument :one").WithArgs(database.MustToDBUUID(docinfo.ID)).
WillReturnRows(
pgxmock.NewRows([]string{"id", "jobId", "hash"}).
AddRow(database.MustToDBUUID(docinfo.ID), database.MustToDBUUID(docinfo.JobID), "example"),
pgxmock.NewRows([]string{"id", "clientId", "hash"}).
AddRow(database.MustToDBUUID(docinfo.ID), database.MustToDBUUID(docinfo.ClientID), "example"),
)
pool.ExpectQuery("name: GetJob :one").WithArgs(database.MustToDBUUID(j.ID)).WillReturnRows(
pgxmock.NewRows([]string{"id", "clientId", "canSync"}).
AddRow(database.MustToDBUUID(j.ID), database.MustToDBUUID(j.ClientID), j.CanSync),
)
pool.ExpectQuery("name: GetClient :one").WithArgs(database.MustToDBUUID(j.ClientID)).
pool.ExpectQuery("name: GetClient :one").WithArgs(database.MustToDBUUID(j.ID)).
WillReturnRows(
pgxmock.NewRows([]string{"id", "name", "canSync"}).
AddRow(database.MustToDBUUID(j.ClientID), "client_name", true),
AddRow(database.MustToDBUUID(j.ID), "client_name", true),
)
mockSQS.EXPECT().
SendMessage(
mock.Anything,
mock.MatchedBy(func(in *sqs.SendMessageInput) bool {
return *in.QueueUrl == cfg.DocumentCleanURL && *in.MessageBody == fmt.Sprintf("{\"id\":\"%s\"}", doc.ID)
}),
mock.Anything,
).
Return(&sqs.SendMessageOutput{}, nil)
assert.True(t, runner.Process(ctx, msg))
})
t.Run("invalid body", func(t *testing.T) {