-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhook_test.go
51 lines (42 loc) · 1004 Bytes
/
hook_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"fmt"
"sync"
"testing"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/sqs"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
)
type MoverMock struct {
mock.Mock
}
func (m *MoverMock) Move(i *sqs.ReceiveMessageInput, t TargetQueues) error {
args := m.Called(i, t)
return args.Error(0)
}
func TestHookToQueueError(t *testing.T) {
// Setup
targ := TargetQueues{"https://queues.com/dummy-dest"}
conf := ProxySettings{
Src: "https://queues.com/dummy-src",
Dest: targ,
}
src := sqs.ReceiveMessageInput{
MaxNumberOfMessages: aws.Int64(10),
WaitTimeSeconds: aws.Int64(20),
QueueUrl: aws.String(conf.Src),
}
m := MoverMock{}
m.On("Move", &src, targ).Return(fmt.Errorf("Dummy Error"))
h := QueueHook{
Mover: &m,
Client: &MockedSQS{},
}
var wg sync.WaitGroup
wg.Add(1)
// Actual tests
assert.Error(t, h.Hook(&conf, &wg))
m.AssertExpectations(t)
m.AssertCalled(t, "Move", &src, targ)
}