7001ca854c
Queuing Changes and Cfg Testing * staarting * staarting * startedpush * note * save * mocking * removederrs * fixtests * cleanuperrs * newenvsetup * preppingtests * queue * mmovetocfgpassunittests * sortoutconfig * passinginteg * deps * fixtests
39 lines
867 B
Go
39 lines
867 B
Go
package queue_test
|
|
|
|
import (
|
|
"context"
|
|
"queryorchestration/internal/server/queue"
|
|
queuemock "queryorchestration/mocks/queue"
|
|
"testing"
|
|
|
|
"github.com/aws/aws-sdk-go-v2/service/sqs"
|
|
"github.com/aws/aws-sdk-go-v2/service/sqs/types"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/mock"
|
|
)
|
|
|
|
func TestReceive(t *testing.T) {
|
|
ctx := context.Background()
|
|
mockSQS := queuemock.NewMockSQSClient(t)
|
|
cfg := &queue.Config{
|
|
URL: "/i/am/here",
|
|
Client: mockSQS,
|
|
}
|
|
|
|
res := sqs.ReceiveMessageOutput{Messages: []types.Message{}}
|
|
|
|
mockSQS.EXPECT().
|
|
ReceiveMessage(
|
|
mock.Anything,
|
|
mock.MatchedBy(func(in *sqs.ReceiveMessageInput) bool {
|
|
return *in.QueueUrl == cfg.URL
|
|
}),
|
|
mock.Anything,
|
|
).
|
|
Return(&res, nil)
|
|
|
|
ares, err := queue.Receive(ctx, cfg, []string{})
|
|
assert.NoError(t, err)
|
|
assert.EqualExportedValues(t, res, *ares)
|
|
}
|