github.com/99designs/gqlgen@v0.17.45/graphql/executable_schema_mock.go (about) 1 // Code generated by moq; DO NOT EDIT. 2 // github.com/matryer/moq 3 4 package graphql 5 6 import ( 7 "context" 8 "github.com/vektah/gqlparser/v2/ast" 9 "sync" 10 ) 11 12 // Ensure, that ExecutableSchemaMock does implement ExecutableSchema. 13 // If this is not the case, regenerate this file with moq. 14 var _ ExecutableSchema = &ExecutableSchemaMock{} 15 16 // ExecutableSchemaMock is a mock implementation of ExecutableSchema. 17 // 18 // func TestSomethingThatUsesExecutableSchema(t *testing.T) { 19 // 20 // // make and configure a mocked ExecutableSchema 21 // mockedExecutableSchema := &ExecutableSchemaMock{ 22 // ComplexityFunc: func(typeName string, fieldName string, childComplexity int, args map[string]interface{}) (int, bool) { 23 // panic("mock out the Complexity method") 24 // }, 25 // ExecFunc: func(ctx context.Context) ResponseHandler { 26 // panic("mock out the Exec method") 27 // }, 28 // SchemaFunc: func() *ast.Schema { 29 // panic("mock out the Schema method") 30 // }, 31 // } 32 // 33 // // use mockedExecutableSchema in code that requires ExecutableSchema 34 // // and then make assertions. 35 // 36 // } 37 type ExecutableSchemaMock struct { 38 // ComplexityFunc mocks the Complexity method. 39 ComplexityFunc func(typeName string, fieldName string, childComplexity int, args map[string]interface{}) (int, bool) 40 41 // ExecFunc mocks the Exec method. 42 ExecFunc func(ctx context.Context) ResponseHandler 43 44 // SchemaFunc mocks the Schema method. 45 SchemaFunc func() *ast.Schema 46 47 // calls tracks calls to the methods. 48 calls struct { 49 // Complexity holds details about calls to the Complexity method. 50 Complexity []struct { 51 // TypeName is the typeName argument value. 52 TypeName string 53 // FieldName is the fieldName argument value. 54 FieldName string 55 // ChildComplexity is the childComplexity argument value. 56 ChildComplexity int 57 // Args is the args argument value. 58 Args map[string]interface{} 59 } 60 // Exec holds details about calls to the Exec method. 61 Exec []struct { 62 // Ctx is the ctx argument value. 63 Ctx context.Context 64 } 65 // Schema holds details about calls to the Schema method. 66 Schema []struct { 67 } 68 } 69 lockComplexity sync.RWMutex 70 lockExec sync.RWMutex 71 lockSchema sync.RWMutex 72 } 73 74 // Complexity calls ComplexityFunc. 75 func (mock *ExecutableSchemaMock) Complexity(typeName string, fieldName string, childComplexity int, args map[string]interface{}) (int, bool) { 76 if mock.ComplexityFunc == nil { 77 panic("ExecutableSchemaMock.ComplexityFunc: method is nil but ExecutableSchema.Complexity was just called") 78 } 79 callInfo := struct { 80 TypeName string 81 FieldName string 82 ChildComplexity int 83 Args map[string]interface{} 84 }{ 85 TypeName: typeName, 86 FieldName: fieldName, 87 ChildComplexity: childComplexity, 88 Args: args, 89 } 90 mock.lockComplexity.Lock() 91 mock.calls.Complexity = append(mock.calls.Complexity, callInfo) 92 mock.lockComplexity.Unlock() 93 return mock.ComplexityFunc(typeName, fieldName, childComplexity, args) 94 } 95 96 // ComplexityCalls gets all the calls that were made to Complexity. 97 // Check the length with: 98 // 99 // len(mockedExecutableSchema.ComplexityCalls()) 100 func (mock *ExecutableSchemaMock) ComplexityCalls() []struct { 101 TypeName string 102 FieldName string 103 ChildComplexity int 104 Args map[string]interface{} 105 } { 106 var calls []struct { 107 TypeName string 108 FieldName string 109 ChildComplexity int 110 Args map[string]interface{} 111 } 112 mock.lockComplexity.RLock() 113 calls = mock.calls.Complexity 114 mock.lockComplexity.RUnlock() 115 return calls 116 } 117 118 // Exec calls ExecFunc. 119 func (mock *ExecutableSchemaMock) Exec(ctx context.Context) ResponseHandler { 120 if mock.ExecFunc == nil { 121 panic("ExecutableSchemaMock.ExecFunc: method is nil but ExecutableSchema.Exec was just called") 122 } 123 callInfo := struct { 124 Ctx context.Context 125 }{ 126 Ctx: ctx, 127 } 128 mock.lockExec.Lock() 129 mock.calls.Exec = append(mock.calls.Exec, callInfo) 130 mock.lockExec.Unlock() 131 return mock.ExecFunc(ctx) 132 } 133 134 // ExecCalls gets all the calls that were made to Exec. 135 // Check the length with: 136 // 137 // len(mockedExecutableSchema.ExecCalls()) 138 func (mock *ExecutableSchemaMock) ExecCalls() []struct { 139 Ctx context.Context 140 } { 141 var calls []struct { 142 Ctx context.Context 143 } 144 mock.lockExec.RLock() 145 calls = mock.calls.Exec 146 mock.lockExec.RUnlock() 147 return calls 148 } 149 150 // Schema calls SchemaFunc. 151 func (mock *ExecutableSchemaMock) Schema() *ast.Schema { 152 if mock.SchemaFunc == nil { 153 panic("ExecutableSchemaMock.SchemaFunc: method is nil but ExecutableSchema.Schema was just called") 154 } 155 callInfo := struct { 156 }{} 157 mock.lockSchema.Lock() 158 mock.calls.Schema = append(mock.calls.Schema, callInfo) 159 mock.lockSchema.Unlock() 160 return mock.SchemaFunc() 161 } 162 163 // SchemaCalls gets all the calls that were made to Schema. 164 // Check the length with: 165 // 166 // len(mockedExecutableSchema.SchemaCalls()) 167 func (mock *ExecutableSchemaMock) SchemaCalls() []struct { 168 } { 169 var calls []struct { 170 } 171 mock.lockSchema.RLock() 172 calls = mock.calls.Schema 173 mock.lockSchema.RUnlock() 174 return calls 175 }