Merged in feature/momocks (pull request #150)

Decrease Mocks

* feature/nomocks

* nonet

* assertsaws

* assert
This commit is contained in:
Michael McGuinness
2025-05-23 00:20:01 +00:00
parent 36ff8096f3
commit 33d68b7e04
42 changed files with 617 additions and 650 deletions
+12 -19
View File
@@ -2,36 +2,37 @@ package clientsyncrunner_test
import (
"fmt"
"regexp"
"testing"
clientsyncrunner "queryorchestration/api/clientSyncRunner"
clientsync "queryorchestration/internal/client/sync"
"queryorchestration/internal/database/repository"
"queryorchestration/internal/server/runner"
"queryorchestration/internal/serviceconfig/objectstore"
"queryorchestration/internal/serviceconfig/queue"
"queryorchestration/internal/serviceconfig/queue/documentsync"
"queryorchestration/internal/test"
queuemock "queryorchestration/mocks/queue"
"github.com/aws/aws-sdk-go-v2/service/sqs"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
)
type ClientSyncConfig struct {
runner.BaseConfig[clientsyncrunner.Body]
documentsync.DocSyncConfig
queue.QueueConfig
objectstore.ObjectStoreConfig
}
func TestQueryRunner(t *testing.T) {
func TestClientSyncRunner(t *testing.T) {
t.Parallel()
cfg := &ClientSyncConfig{}
net := test.GetNetwork(t)
test.CreateDB(t, cfg, net, &test.CreateDatabaseConfig{})
test.CreateDB(t, cfg)
acfg := test.CreateAWSContainer(t, cfg)
mockSQS := queuemock.NewMockSQSClient(t)
cfg.QueueClient = mockSQS
cfg.DocumentSyncURL = "/i/am/here"
test.SetQueueClient(t, t.Context(), cfg, acfg.ExternalEndpoint)
cfg.DocumentSyncURL = test.CreateQueue(t, cfg, test.DocSyncRunnerName)
svc := clientsync.New(cfg)
@@ -54,15 +55,7 @@ func TestQueryRunner(t *testing.T) {
ClientID: "client_id",
}
mockSQS.EXPECT().
SendMessage(
mock.Anything,
mock.MatchedBy(func(in *sqs.SendMessageInput) bool {
return *in.QueueUrl == cfg.DocumentSyncURL && *in.MessageBody == fmt.Sprintf("{\"id\":\"%s\"}", docId.String())
}),
mock.Anything,
).
Return(&sqs.SendMessageOutput{}, nil)
assert.True(t, runner.Process(t.Context(), bod))
test.AssertMessageBody(t, cfg, cfg.GetDocumentSyncURL(), regexp.MustCompile(fmt.Sprintf(`{"id":"%s"}`, docId.String())))
}