From a9a3b214f2278d4d7d73fb33750f32a9f7ada8a0 Mon Sep 17 00:00:00 2001 From: Steve Coffman Date: Wed, 21 Sep 2022 09:45:31 -0400 Subject: [PATCH] Avoid double pointer Signed-off-by: Steve Coffman --- client/websocket.go | 4 ++ codegen/testserver/followschema/models-gen.go | 2 +- codegen/testserver/singlefile/models-gen.go | 2 +- graphql/executable_schema_mock.go | 41 ++++++++++--------- 4 files changed, 28 insertions(+), 21 deletions(-) diff --git a/client/websocket.go b/client/websocket.go index 016691e10c0..d1e287b892d 100644 --- a/client/websocket.go +++ b/client/websocket.go @@ -5,6 +5,7 @@ import ( "fmt" "io" "net/http/httptest" + "reflect" "strings" "github.com/gorilla/websocket" @@ -47,6 +48,9 @@ func (p *Client) Websocket(query string, options ...Option) *Subscription { func (p *Client) WebsocketOnce(query string, resp interface{}, options ...Option) error { sock := p.Websocket(query, options...) defer sock.Close() + if reflect.ValueOf(resp).Kind() == reflect.Ptr { + return sock.Next(resp) + } return sock.Next(&resp) } diff --git a/codegen/testserver/followschema/models-gen.go b/codegen/testserver/followschema/models-gen.go index 0cc3b4a24e6..875941bef29 100644 --- a/codegen/testserver/followschema/models-gen.go +++ b/codegen/testserver/followschema/models-gen.go @@ -220,7 +220,7 @@ type ValidInput struct { Underscore string `json:"_"` } -// These things are all valid, but without care generate invalid go code +// These things are all valid, but without care generate invalid go code type ValidType struct { DifferentCase string `json:"differentCase"` DifferentCaseOld string `json:"different_case"` diff --git a/codegen/testserver/singlefile/models-gen.go b/codegen/testserver/singlefile/models-gen.go index 53afbdf3fd9..5ab72058e3b 100644 --- a/codegen/testserver/singlefile/models-gen.go +++ b/codegen/testserver/singlefile/models-gen.go @@ -220,7 +220,7 @@ type ValidInput struct { Underscore string `json:"_"` } -// These things are all valid, but without care generate invalid go code +// These things are all valid, but without care generate invalid go code type ValidType struct { DifferentCase string `json:"differentCase"` DifferentCaseOld string `json:"different_case"` diff --git a/graphql/executable_schema_mock.go b/graphql/executable_schema_mock.go index 5d7433162fe..5e71cb83040 100644 --- a/graphql/executable_schema_mock.go +++ b/graphql/executable_schema_mock.go @@ -15,25 +15,25 @@ var _ ExecutableSchema = &ExecutableSchemaMock{} // ExecutableSchemaMock is a mock implementation of ExecutableSchema. // -// func TestSomethingThatUsesExecutableSchema(t *testing.T) { +// 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") -// }, -// } +// // 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. +// // 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) @@ -95,7 +95,8 @@ func (mock *ExecutableSchemaMock) Complexity(typeName string, fieldName string, // ComplexityCalls gets all the calls that were made to Complexity. // Check the length with: -// len(mockedExecutableSchema.ComplexityCalls()) +// +// len(mockedExecutableSchema.ComplexityCalls()) func (mock *ExecutableSchemaMock) ComplexityCalls() []struct { TypeName string FieldName string @@ -132,7 +133,8 @@ func (mock *ExecutableSchemaMock) Exec(ctx context.Context) ResponseHandler { // ExecCalls gets all the calls that were made to Exec. // Check the length with: -// len(mockedExecutableSchema.ExecCalls()) +// +// len(mockedExecutableSchema.ExecCalls()) func (mock *ExecutableSchemaMock) ExecCalls() []struct { Ctx context.Context } { @@ -160,7 +162,8 @@ func (mock *ExecutableSchemaMock) Schema() *ast.Schema { // SchemaCalls gets all the calls that were made to Schema. // Check the length with: -// len(mockedExecutableSchema.SchemaCalls()) +// +// len(mockedExecutableSchema.SchemaCalls()) func (mock *ExecutableSchemaMock) SchemaCalls() []struct { } { var calls []struct {