7001ca854c
Queuing Changes and Cfg Testing * staarting * staarting * startedpush * note * save * mocking * removederrs * fixtests * cleanuperrs * newenvsetup * preppingtests * queue * mmovetocfgpassunittests * sortoutconfig * passinginteg * deps * fixtests
41 lines
884 B
Go
41 lines
884 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 TestDelete(t *testing.T) {
|
|
ctx := context.Background()
|
|
mockSQS := queuemock.NewMockSQSClient(t)
|
|
cfg := &queue.Config{
|
|
URL: "/i/am/here",
|
|
Client: mockSQS,
|
|
}
|
|
handle := "iamahandler"
|
|
|
|
mockSQS.EXPECT().
|
|
DeleteMessage(
|
|
mock.Anything,
|
|
mock.MatchedBy(func(in *sqs.DeleteMessageInput) bool {
|
|
return *in.QueueUrl == cfg.URL && *in.ReceiptHandle == handle
|
|
}),
|
|
mock.Anything,
|
|
).
|
|
Return(&sqs.DeleteMessageOutput{}, nil)
|
|
|
|
message := &types.Message{
|
|
ReceiptHandle: &handle,
|
|
}
|
|
|
|
err := queue.Delete(ctx, cfg, message)
|
|
assert.NoError(t, err)
|
|
}
|