-
Notifications
You must be signed in to change notification settings - Fork 2
/
mocker.go
65 lines (55 loc) · 1.48 KB
/
mocker.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package bus
import (
"context"
"time"
"github.com/stretchr/testify/mock"
)
type mockDriver struct {
mock.Mock
itd *internalDriver
}
func (m *mockDriver) CreateQueue(name string, delay time.Duration) error {
err := m.Called(name, delay).Error(0)
if err == nil {
err = m.itd.CreateQueue(name, delay)
}
return err
}
func (m *mockDriver) CreateTopic(name string) error {
err := m.Called(name).Error(0)
if err == nil {
err = m.itd.CreateTopic(name)
}
return err
}
func (m *mockDriver) Subscribe(topic, queue, routeKey string) error {
err := m.Called(topic, queue, routeKey).Error(0)
if err == nil {
err = m.itd.Subscribe(topic, queue, routeKey)
}
return err
}
func (m *mockDriver) UnSubscribe(topic, queue, routeKey string) error {
err := m.Called(topic, queue, routeKey).Error(0)
if err == nil {
err = m.itd.UnSubscribe(topic, queue, routeKey)
}
return err
}
func (m *mockDriver) SendToQueue(queue string, content []byte, delay time.Duration) error {
err := m.Called(queue, content, delay).Error(0)
if err == nil {
err = m.itd.SendToQueue(queue, content, delay)
}
return err
}
func (m *mockDriver) SendToTopic(topic string, content []byte, routeKey string) error {
err := m.Called(topic, content, routeKey).Error(0)
if err == nil {
err = m.itd.SendToTopic(topic, content, routeKey)
}
return err
}
func (m *mockDriver) ReceiveMessage(ctx context.Context, queue string, errChan chan error, handler func([]byte) bool) {
m.itd.ReceiveMessage(ctx, queue, errChan, handler)
}