/
executable_schema_mock.go
175 lines (162 loc) · 4.89 KB
/
executable_schema_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
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
// Code generated by moq; DO NOT EDIT.
// github.com/matryer/moq
package graphql
import (
"context"
"github.com/vektah/gqlparser/v2/ast"
"sync"
)
// Ensure, that ExecutableSchemaMock does implement ExecutableSchema.
// If this is not the case, regenerate this file with moq.
var _ ExecutableSchema = &ExecutableSchemaMock{}
// ExecutableSchemaMock is a mock implementation of ExecutableSchema.
//
// func TestSomethingThatUsesExecutableSchema(t *testing.T) {
//
// // make and configure a mocked ExecutableSchema
// mockedExecutableSchema := &ExecutableSchemaMock{
// ComplexityFunc: func(typeName string, fieldName string, childComplexity int, args map[string]interface{}) (int, bool) {
// panic("mock out the Complexity method")
// },
// ExecFunc: func(ctx context.Context) ResponseHandler {
// panic("mock out the Exec method")
// },
// SchemaFunc: func() *ast.Schema {
// panic("mock out the Schema method")
// },
// }
//
// // use mockedExecutableSchema in code that requires ExecutableSchema
// // and then make assertions.
//
// }
type ExecutableSchemaMock struct {
// ComplexityFunc mocks the Complexity method.
ComplexityFunc func(typeName string, fieldName string, childComplexity int, args map[string]interface{}) (int, bool)
// ExecFunc mocks the Exec method.
ExecFunc func(ctx context.Context) ResponseHandler
// SchemaFunc mocks the Schema method.
SchemaFunc func() *ast.Schema
// calls tracks calls to the methods.
calls struct {
// Complexity holds details about calls to the Complexity method.
Complexity []struct {
// TypeName is the typeName argument value.
TypeName string
// FieldName is the fieldName argument value.
FieldName string
// ChildComplexity is the childComplexity argument value.
ChildComplexity int
// Args is the args argument value.
Args map[string]interface{}
}
// Exec holds details about calls to the Exec method.
Exec []struct {
// Ctx is the ctx argument value.
Ctx context.Context
}
// Schema holds details about calls to the Schema method.
Schema []struct {
}
}
lockComplexity sync.RWMutex
lockExec sync.RWMutex
lockSchema sync.RWMutex
}
// Complexity calls ComplexityFunc.
func (mock *ExecutableSchemaMock) Complexity(typeName string, fieldName string, childComplexity int, args map[string]interface{}) (int, bool) {
if mock.ComplexityFunc == nil {
panic("ExecutableSchemaMock.ComplexityFunc: method is nil but ExecutableSchema.Complexity was just called")
}
callInfo := struct {
TypeName string
FieldName string
ChildComplexity int
Args map[string]interface{}
}{
TypeName: typeName,
FieldName: fieldName,
ChildComplexity: childComplexity,
Args: args,
}
mock.lockComplexity.Lock()
mock.calls.Complexity = append(mock.calls.Complexity, callInfo)
mock.lockComplexity.Unlock()
return mock.ComplexityFunc(typeName, fieldName, childComplexity, args)
}
// ComplexityCalls gets all the calls that were made to Complexity.
// Check the length with:
//
// len(mockedExecutableSchema.ComplexityCalls())
func (mock *ExecutableSchemaMock) ComplexityCalls() []struct {
TypeName string
FieldName string
ChildComplexity int
Args map[string]interface{}
} {
var calls []struct {
TypeName string
FieldName string
ChildComplexity int
Args map[string]interface{}
}
mock.lockComplexity.RLock()
calls = mock.calls.Complexity
mock.lockComplexity.RUnlock()
return calls
}
// Exec calls ExecFunc.
func (mock *ExecutableSchemaMock) Exec(ctx context.Context) ResponseHandler {
if mock.ExecFunc == nil {
panic("ExecutableSchemaMock.ExecFunc: method is nil but ExecutableSchema.Exec was just called")
}
callInfo := struct {
Ctx context.Context
}{
Ctx: ctx,
}
mock.lockExec.Lock()
mock.calls.Exec = append(mock.calls.Exec, callInfo)
mock.lockExec.Unlock()
return mock.ExecFunc(ctx)
}
// ExecCalls gets all the calls that were made to Exec.
// Check the length with:
//
// len(mockedExecutableSchema.ExecCalls())
func (mock *ExecutableSchemaMock) ExecCalls() []struct {
Ctx context.Context
} {
var calls []struct {
Ctx context.Context
}
mock.lockExec.RLock()
calls = mock.calls.Exec
mock.lockExec.RUnlock()
return calls
}
// Schema calls SchemaFunc.
func (mock *ExecutableSchemaMock) Schema() *ast.Schema {
if mock.SchemaFunc == nil {
panic("ExecutableSchemaMock.SchemaFunc: method is nil but ExecutableSchema.Schema was just called")
}
callInfo := struct {
}{}
mock.lockSchema.Lock()
mock.calls.Schema = append(mock.calls.Schema, callInfo)
mock.lockSchema.Unlock()
return mock.SchemaFunc()
}
// SchemaCalls gets all the calls that were made to Schema.
// Check the length with:
//
// len(mockedExecutableSchema.SchemaCalls())
func (mock *ExecutableSchemaMock) SchemaCalls() []struct {
} {
var calls []struct {
}
mock.lockSchema.RLock()
calls = mock.calls.Schema
mock.lockSchema.RUnlock()
return calls
}