-
Notifications
You must be signed in to change notification settings - Fork 1
/
mock_errorreporter_test.go
137 lines (117 loc) · 5.05 KB
/
mock_errorreporter_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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
// Code generated by pegomock. DO NOT EDIT.
// Source: github.com/petergtz/alexa-journal (interfaces: ErrorReporter)
package journalskill_test
import (
go_alexa "github.com/petergtz/go-alexa"
pegomock "github.com/petergtz/pegomock"
"reflect"
"time"
)
type MockErrorReporter struct {
fail func(message string, callerSkip ...int)
}
func NewMockErrorReporter(options ...pegomock.Option) *MockErrorReporter {
mock := &MockErrorReporter{}
for _, option := range options {
option.Apply(mock)
}
return mock
}
func (mock *MockErrorReporter) SetFailHandler(fh pegomock.FailHandler) { mock.fail = fh }
func (mock *MockErrorReporter) FailHandler() pegomock.FailHandler { return mock.fail }
func (mock *MockErrorReporter) ReportPanic(e interface{}, requestEnv *go_alexa.RequestEnvelope) {
if mock == nil {
panic("mock must not be nil. Use myMock := NewMockErrorReporter().")
}
params := []pegomock.Param{e, requestEnv}
pegomock.GetGenericMockFrom(mock).Invoke("ReportPanic", params, []reflect.Type{})
}
func (mock *MockErrorReporter) ReportError(e error) {
if mock == nil {
panic("mock must not be nil. Use myMock := NewMockErrorReporter().")
}
params := []pegomock.Param{e}
pegomock.GetGenericMockFrom(mock).Invoke("ReportError", params, []reflect.Type{})
}
func (mock *MockErrorReporter) VerifyWasCalledOnce() *VerifierMockErrorReporter {
return &VerifierMockErrorReporter{
mock: mock,
invocationCountMatcher: pegomock.Times(1),
}
}
func (mock *MockErrorReporter) VerifyWasCalled(invocationCountMatcher pegomock.InvocationCountMatcher) *VerifierMockErrorReporter {
return &VerifierMockErrorReporter{
mock: mock,
invocationCountMatcher: invocationCountMatcher,
}
}
func (mock *MockErrorReporter) VerifyWasCalledInOrder(invocationCountMatcher pegomock.InvocationCountMatcher, inOrderContext *pegomock.InOrderContext) *VerifierMockErrorReporter {
return &VerifierMockErrorReporter{
mock: mock,
invocationCountMatcher: invocationCountMatcher,
inOrderContext: inOrderContext,
}
}
func (mock *MockErrorReporter) VerifyWasCalledEventually(invocationCountMatcher pegomock.InvocationCountMatcher, timeout time.Duration) *VerifierMockErrorReporter {
return &VerifierMockErrorReporter{
mock: mock,
invocationCountMatcher: invocationCountMatcher,
timeout: timeout,
}
}
type VerifierMockErrorReporter struct {
mock *MockErrorReporter
invocationCountMatcher pegomock.InvocationCountMatcher
inOrderContext *pegomock.InOrderContext
timeout time.Duration
}
func (verifier *VerifierMockErrorReporter) ReportPanic(e interface{}, requestEnv *go_alexa.RequestEnvelope) *MockErrorReporter_ReportPanic_OngoingVerification {
params := []pegomock.Param{e, requestEnv}
methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "ReportPanic", params, verifier.timeout)
return &MockErrorReporter_ReportPanic_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations}
}
type MockErrorReporter_ReportPanic_OngoingVerification struct {
mock *MockErrorReporter
methodInvocations []pegomock.MethodInvocation
}
func (c *MockErrorReporter_ReportPanic_OngoingVerification) GetCapturedArguments() (interface{}, *go_alexa.RequestEnvelope) {
e, requestEnv := c.GetAllCapturedArguments()
return e[len(e)-1], requestEnv[len(requestEnv)-1]
}
func (c *MockErrorReporter_ReportPanic_OngoingVerification) GetAllCapturedArguments() (_param0 []interface{}, _param1 []*go_alexa.RequestEnvelope) {
params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations)
if len(params) > 0 {
_param0 = make([]interface{}, len(c.methodInvocations))
for u, param := range params[0] {
_param0[u] = param.(interface{})
}
_param1 = make([]*go_alexa.RequestEnvelope, len(c.methodInvocations))
for u, param := range params[1] {
_param1[u] = param.(*go_alexa.RequestEnvelope)
}
}
return
}
func (verifier *VerifierMockErrorReporter) ReportError(e error) *MockErrorReporter_ReportError_OngoingVerification {
params := []pegomock.Param{e}
methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "ReportError", params, verifier.timeout)
return &MockErrorReporter_ReportError_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations}
}
type MockErrorReporter_ReportError_OngoingVerification struct {
mock *MockErrorReporter
methodInvocations []pegomock.MethodInvocation
}
func (c *MockErrorReporter_ReportError_OngoingVerification) GetCapturedArguments() error {
e := c.GetAllCapturedArguments()
return e[len(e)-1]
}
func (c *MockErrorReporter_ReportError_OngoingVerification) GetAllCapturedArguments() (_param0 []error) {
params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations)
if len(params) > 0 {
_param0 = make([]error, len(c.methodInvocations))
for u, param := range params[0] {
_param0[u] = param.(error)
}
}
return
}