-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmocks_test.go
50 lines (40 loc) · 907 Bytes
/
mocks_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
package main
import (
"encoding/json"
)
func MockMessage(body, topic string) Message {
msg := map[string]string{
"Message": body,
"TopicArn": topic,
}
data, err := json.Marshal(msg)
if err != nil {
panic(err)
}
return Message{Body: string(data)}
}
type MockSQSClient struct {
Fetchable []Message
FetchError error
Deleted []Message
DeleteError error
}
func (m *MockSQSClient) Fetch() ([]Message, error) {
if m.FetchError != nil {
return nil, m.FetchError
}
return m.Fetchable, nil
}
func (m *MockSQSClient) Delete(message Message) error {
m.Deleted = append(m.Deleted, message)
return m.DeleteError
}
type MockWorkerClient struct {
Enqueued [][]string
EnqueuedJID string
EnqueueError error
}
func (m *MockWorkerClient) Push(class, args string) (string, error) {
m.Enqueued = append(m.Enqueued, []string{class, args})
return m.EnqueuedJID, m.EnqueueError
}