-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmoka_suite_test.go
66 lines (53 loc) · 1.58 KB
/
moka_suite_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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package moka
import (
"reflect"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"testing"
)
func TestMoka(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Moka Suite")
}
type fakeInteraction struct {
callCalled bool
receivedMethodName string
receivedArgs []interface{}
returnValues []interface{}
matches bool
verifyCalled bool
verifyError error
checkTypeCalled bool
receivedType reflect.Type
checkTypeError error
}
func newFakeInteraction(returnValues []interface{}, matches bool, verifyError error, checkTypeError error) *fakeInteraction {
return &fakeInteraction{returnValues: returnValues, matches: matches, verifyError: verifyError, checkTypeError: checkTypeError}
}
func (i *fakeInteraction) call(methodName string, args []interface{}) ([]interface{}, bool) {
i.callCalled = true
i.receivedMethodName = methodName
i.receivedArgs = args
return i.returnValues, i.matches
}
func (i *fakeInteraction) verify() error {
i.verifyCalled = true
return i.verifyError
}
func (i *fakeInteraction) checkType(t reflect.Type) error {
i.checkTypeCalled = true
i.receivedType = t
return i.checkTypeError
}
func (i *fakeInteraction) String() string {
return "<the-interaction-string-representation>"
}
type fakeInteractionValidator struct {
validationError error
}
func newFakeInteractionValidator(validationError error) fakeInteractionValidator {
return fakeInteractionValidator{validationError: validationError}
}
func (v fakeInteractionValidator) validate(interaction interaction) error {
return v.validationError
}