This repository has been archived by the owner on Jul 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
client_mock.go
74 lines (56 loc) · 1.59 KB
/
client_mock.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
66
67
68
69
70
71
72
73
74
package rspamd
import (
"context"
"github.com/stretchr/testify/mock"
)
// client's usage
var _ Client = &mockClient{}
// NewMock creates a mock client, which can be used wherever client is used, to test/
func NewMock() *mockClient {
return &mockClient{}
}
type mockClient struct {
mock.Mock
}
func (m *mockClient) Check(ctx context.Context, cr *CheckRequest) (*CheckResponse, error) {
args := m.Called(ctx, cr)
if args.Error(1) != nil {
return nil, args.Error(1)
}
return args.Get(0).(*CheckResponse), nil
}
func (m *mockClient) LearnSpam(ctx context.Context, lr *LearnRequest) (*LearnResponse, error) {
args := m.Called(ctx, lr)
if args.Error(1) != nil {
return nil, args.Error(1)
}
return args.Get(0).(*LearnResponse), nil
}
func (m *mockClient) LearnHam(ctx context.Context, lr *LearnRequest) (*LearnResponse, error) {
args := m.Called(ctx, lr)
if args.Error(1) != nil {
return nil, args.Error(1)
}
return args.Get(0).(*LearnResponse), nil
}
func (m *mockClient) FuzzyAdd(ctx context.Context, fr *FuzzyRequest) (*FuzzyResponse, error) {
args := m.Called(ctx, fr)
if args.Error(1) != nil {
return nil, args.Error(1)
}
return args.Get(0).(*FuzzyResponse), nil
}
func (m *mockClient) FuzzyDel(ctx context.Context, fr *FuzzyRequest) (*FuzzyResponse, error) {
args := m.Called(ctx, fr)
if args.Error(1) != nil {
return nil, args.Error(1)
}
return args.Get(0).(*FuzzyResponse), nil
}
func (m *mockClient) Ping(ctx context.Context) (PingResponse, error) {
args := m.Called(ctx)
if args.Error(1) != nil {
return "", args.Error(1)
}
return args.Get(0).(PingResponse), nil
}