github.com/mstephano/gqlgen-schemagen@v0.0.0-20230113041936-dd2cd4ea46aa/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 // len(mockedExecutableSchema.ComplexityCalls()) 99 func (mock *ExecutableSchemaMock) ComplexityCalls() []struct { 100 TypeName string 101 FieldName string 102 ChildComplexity int 103 Args map[string]interface{} 104 } { 105 var calls []struct { 106 TypeName string 107 FieldName string 108 ChildComplexity int 109 Args map[string]interface{} 110 } 111 mock.lockComplexity.RLock() 112 calls = mock.calls.Complexity 113 mock.lockComplexity.RUnlock() 114 return calls 115 } 116 117 // Exec calls ExecFunc. 118 func (mock *ExecutableSchemaMock) Exec(ctx context.Context) ResponseHandler { 119 if mock.ExecFunc == nil { 120 panic("ExecutableSchemaMock.ExecFunc: method is nil but ExecutableSchema.Exec was just called") 121 } 122 callInfo := struct { 123 Ctx context.Context 124 }{ 125 Ctx: ctx, 126 } 127 mock.lockExec.Lock() 128 mock.calls.Exec = append(mock.calls.Exec, callInfo) 129 mock.lockExec.Unlock() 130 return mock.ExecFunc(ctx) 131 } 132 133 // ExecCalls gets all the calls that were made to Exec. 134 // Check the length with: 135 // len(mockedExecutableSchema.ExecCalls()) 136 func (mock *ExecutableSchemaMock) ExecCalls() []struct { 137 Ctx context.Context 138 } { 139 var calls []struct { 140 Ctx context.Context 141 } 142 mock.lockExec.RLock() 143 calls = mock.calls.Exec 144 mock.lockExec.RUnlock() 145 return calls 146 } 147 148 // Schema calls SchemaFunc. 149 func (mock *ExecutableSchemaMock) Schema() *ast.Schema { 150 if mock.SchemaFunc == nil { 151 panic("ExecutableSchemaMock.SchemaFunc: method is nil but ExecutableSchema.Schema was just called") 152 } 153 callInfo := struct { 154 }{} 155 mock.lockSchema.Lock() 156 mock.calls.Schema = append(mock.calls.Schema, callInfo) 157 mock.lockSchema.Unlock() 158 return mock.SchemaFunc() 159 } 160 161 // SchemaCalls gets all the calls that were made to Schema. 162 // Check the length with: 163 // len(mockedExecutableSchema.SchemaCalls()) 164 func (mock *ExecutableSchemaMock) SchemaCalls() []struct { 165 } { 166 var calls []struct { 167 } 168 mock.lockSchema.RLock() 169 calls = mock.calls.Schema 170 mock.lockSchema.RUnlock() 171 return calls 172 }