/
verifier.go
75 lines (62 loc) · 2.46 KB
/
verifier.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
75
package mocks
import (
"github.com/steinfletcher/apitest"
)
var _ apitest.Verifier = MockVerifier{}
// MockVerifier is a mock of the Verifier interface that is used in tests of apitest
type MockVerifier struct {
EqualFn func(t apitest.TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool
EqualInvoked bool
TrueFn func(t apitest.TestingT, val bool, msgAndArgs ...interface{}) bool
TrueInvoked bool
JSONEqFn func(t apitest.TestingT, expected string, actual string, msgAndArgs ...interface{}) bool
JSONEqInvoked bool
FailFn func(t apitest.TestingT, failureMessage string, msgAndArgs ...interface{}) bool
FailInvoked bool
NoErrorFn func(t apitest.TestingT, err error, msgAndArgs ...interface{}) bool
NoErrorInvoked bool
}
func NewVerifier() MockVerifier {
return MockVerifier{
EqualFn: func(t apitest.TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool {
return true
},
JSONEqFn: func(t apitest.TestingT, expected string, actual string, msgAndArgs ...interface{}) bool {
return true
},
FailFn: func(t apitest.TestingT, failureMessage string, msgAndArgs ...interface{}) bool {
return true
},
NoErrorFn: func(t apitest.TestingT, err error, msgAndArgs ...interface{}) bool {
return true
},
TrueFn: func(t apitest.TestingT, val bool, msgAndArgs ...interface{}) bool {
return true
},
}
}
// Equal mocks the Equal method of the Verifier
func (m MockVerifier) Equal(t apitest.TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool {
m.EqualInvoked = true
return m.EqualFn(t, expected, actual, msgAndArgs)
}
// True mocks the Equal method of the Verifier
func (m MockVerifier) True(t apitest.TestingT, val bool, msgAndArgs ...interface{}) bool {
m.TrueInvoked = true
return m.TrueFn(t, val, msgAndArgs)
}
// JSONEq mocks the JSONEq method of the Verifier
func (m MockVerifier) JSONEq(t apitest.TestingT, expected string, actual string, msgAndArgs ...interface{}) bool {
m.JSONEqInvoked = true
return m.JSONEqFn(t, expected, actual, msgAndArgs)
}
// Fail mocks the Fail method of the Verifier
func (m MockVerifier) Fail(t apitest.TestingT, failureMessage string, msgAndArgs ...interface{}) bool {
m.FailInvoked = true
return m.FailFn(t, failureMessage, msgAndArgs)
}
// NoError asserts that a function returned no error
func (m MockVerifier) NoError(t apitest.TestingT, err error, msgAndArgs ...interface{}) bool {
m.NoErrorInvoked = true
return m.NoErrorFn(t, err, msgAndArgs)
}