Skip to content

Commit 3290060

Browse files
pavelnikolovKNiepok
authored andcommitted
fix lint errors (graph-gophers#566)
1 parent 89c4a71 commit 3290060

File tree

4 files changed

+48
-57
lines changed

4 files changed

+48
-57
lines changed

graphql_test.go

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -148,21 +148,12 @@ func (e resolverNotFoundError) Extensions() map[string]interface{} {
148148
}
149149
}
150150

151-
type findDroidResolver struct{}
152-
153-
func (r *findDroidResolver) FindDroid(ctx context.Context) (string, error) {
154-
return "", resolverNotFoundError{
155-
Code: "NotFound",
156-
Message: "This is not the droid you are looking for",
157-
}
158-
}
159-
160151
var (
161152
droidNotFoundError = resolverNotFoundError{
162153
Code: "NotFound",
163154
Message: "This is not the droid you are looking for",
164155
}
165-
quoteError = errors.New("Bleep bloop")
156+
errQuote = errors.New("bleep bloop")
166157

167158
r2d2 = &droidResolver{name: "R2-D2"}
168159
c3po = &droidResolver{name: "C-3PO"}
@@ -205,7 +196,7 @@ func (d *droidResolver) Name() (string, error) {
205196
func (d *droidResolver) Quotes() ([]string, error) {
206197
switch d.name {
207198
case r2d2.name:
208-
return nil, quoteError
199+
return nil, errQuote
209200
case c3po.name:
210201
return []string{"We're doomed!", "R2-D2, where are you?"}, nil
211202
}
@@ -818,7 +809,7 @@ func TestBasic(t *testing.T) {
818809

819810
type testEmbeddedStructResolver struct{}
820811

821-
func (_ *testEmbeddedStructResolver) Course() courseResolver {
812+
func (*testEmbeddedStructResolver) Course() courseResolver {
822813
return courseResolver{
823814
CourseMeta: CourseMeta{
824815
Name: "Biology",
@@ -1139,8 +1130,8 @@ func TestErrorPropagationInLists(t *testing.T) {
11391130
`,
11401131
ExpectedErrors: []*gqlerrors.QueryError{
11411132
{
1142-
Message: quoteError.Error(),
1143-
ResolverError: quoteError,
1133+
Message: errQuote.Error(),
1134+
ResolverError: errQuote,
11441135
Path: []interface{}{"findDroids", 0, "quotes"},
11451136
},
11461137
},
@@ -1174,8 +1165,8 @@ func TestErrorPropagationInLists(t *testing.T) {
11741165
`,
11751166
ExpectedErrors: []*gqlerrors.QueryError{
11761167
{
1177-
Message: quoteError.Error(),
1178-
ResolverError: quoteError,
1168+
Message: errQuote.Error(),
1169+
ResolverError: errQuote,
11791170
Path: []interface{}{"findNilDroids", 0, "quotes"},
11801171
},
11811172
{
@@ -3091,7 +3082,7 @@ func TestTime(t *testing.T) {
30913082

30923083
type resolverWithUnexportedMethod struct{}
30933084

3094-
func (r *resolverWithUnexportedMethod) changeTheNumber(args struct{ NewNumber int32 }) int32 {
3085+
func (r *resolverWithUnexportedMethod) changeTheNumber(args struct{ NewNumber int32 }) int32 { //lint:ignore U1000 ingore this for now
30953086
return args.NewNumber
30963087
}
30973088

@@ -3641,15 +3632,15 @@ func TestComposedFragments(t *testing.T) {
36413632
}
36423633

36433634
var (
3644-
exampleError = fmt.Errorf("This is an error")
3635+
errExample = fmt.Errorf("this is an error")
36453636

36463637
nilChildErrorString = `graphql: got nil for non-null "Child"`
36473638
)
36483639

36493640
type childResolver struct{}
36503641

36513642
func (r *childResolver) TriggerError() (string, error) {
3652-
return "This will never be returned to the client", exampleError
3643+
return "This will never be returned to the client", errExample
36533644
}
36543645
func (r *childResolver) NoError() string {
36553646
return "no error"
@@ -3687,8 +3678,8 @@ func TestErrorPropagation(t *testing.T) {
36873678
`,
36883679
ExpectedErrors: []*gqlerrors.QueryError{
36893680
{
3690-
Message: exampleError.Error(),
3691-
ResolverError: exampleError,
3681+
Message: errExample.Error(),
3682+
ResolverError: errExample,
36923683
Path: []interface{}{"triggerError"},
36933684
},
36943685
},
@@ -3726,8 +3717,8 @@ func TestErrorPropagation(t *testing.T) {
37263717
`,
37273718
ExpectedErrors: []*gqlerrors.QueryError{
37283719
{
3729-
Message: exampleError.Error(),
3730-
ResolverError: exampleError,
3720+
Message: errExample.Error(),
3721+
ResolverError: errExample,
37313722
Path: []interface{}{"child", "triggerError"},
37323723
},
37333724
},
@@ -3769,8 +3760,8 @@ func TestErrorPropagation(t *testing.T) {
37693760
`,
37703761
ExpectedErrors: []*gqlerrors.QueryError{
37713762
{
3772-
Message: exampleError.Error(),
3773-
ResolverError: exampleError,
3763+
Message: errExample.Error(),
3764+
ResolverError: errExample,
37743765
Path: []interface{}{"child", "child", "triggerError"},
37753766
},
37763767
},
@@ -3815,8 +3806,8 @@ func TestErrorPropagation(t *testing.T) {
38153806
`,
38163807
ExpectedErrors: []*gqlerrors.QueryError{
38173808
{
3818-
Message: exampleError.Error(),
3819-
ResolverError: exampleError,
3809+
Message: errExample.Error(),
3810+
ResolverError: errExample,
38203811
Path: []interface{}{"child", "child", "triggerError"},
38213812
},
38223813
},
@@ -3940,8 +3931,8 @@ func TestErrorPropagation(t *testing.T) {
39403931
Path: []interface{}{"child", "child", "child", "nilChild"},
39413932
},
39423933
{
3943-
Message: exampleError.Error(),
3944-
ResolverError: exampleError,
3934+
Message: errExample.Error(),
3935+
ResolverError: errExample,
39453936
Path: []interface{}{"child", "child", "triggerError"},
39463937
},
39473938
},
@@ -5087,7 +5078,7 @@ func TestSeparateResolvers(t *testing.T) {
50875078
{
50885079
// null propagates all the way up because msg is non-null
50895080
Data: json.RawMessage(`null`),
5090-
Errors: []*gqlerrors.QueryError{gqlerrors.Errorf("%s", resolverErr)},
5081+
Errors: []*gqlerrors.QueryError{gqlerrors.Errorf("%s", errResolver)},
50915082
},
50925083
{
50935084
Data: json.RawMessage(`

nullable_types_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"math"
55
"testing"
66

7-
. "github.com/graph-gophers/graphql-go"
7+
"github.com/graph-gophers/graphql-go"
88
"github.com/graph-gophers/graphql-go/decode"
99
)
1010

@@ -16,7 +16,7 @@ func TestNullInt_ImplementsUnmarshaler(t *testing.T) {
1616
}()
1717

1818
// assert *NullInt implements decode.Unmarshaler interface
19-
var _ decode.Unmarshaler = (*NullInt)(nil)
19+
var _ decode.Unmarshaler = (*graphql.NullInt)(nil)
2020
}
2121

2222
func TestNullInt_UnmarshalGraphQL(t *testing.T) {
@@ -28,7 +28,7 @@ func TestNullInt_UnmarshalGraphQL(t *testing.T) {
2828
b := float64(math.MinInt32 - 1)
2929
c := 1234.6
3030
good := int32(1234)
31-
ref := NullInt{
31+
ref := graphql.NullInt{
3232
Value: &good,
3333
Set: true,
3434
}
@@ -69,7 +69,7 @@ func TestNullInt_UnmarshalGraphQL(t *testing.T) {
6969

7070
for _, tt := range tests {
7171
t.Run(tt.name, func(t *testing.T) {
72-
gt := new(NullInt)
72+
gt := &graphql.NullInt{}
7373
if err := gt.UnmarshalGraphQL(tt.args.input); err != nil {
7474
if err.Error() != tt.wantErr {
7575
t.Errorf("UnmarshalGraphQL() error = %v, want = %s", err, tt.wantErr)
@@ -86,7 +86,7 @@ func TestNullInt_UnmarshalGraphQL(t *testing.T) {
8686
tests := []struct {
8787
name string
8888
args args
89-
wantEq NullInt
89+
wantEq graphql.NullInt
9090
}{
9191
{
9292
name: "int32",
@@ -106,7 +106,7 @@ func TestNullInt_UnmarshalGraphQL(t *testing.T) {
106106

107107
for _, tt := range tests {
108108
t.Run(tt.name, func(t *testing.T) {
109-
gt := new(NullInt)
109+
gt := new(graphql.NullInt)
110110
if err := gt.UnmarshalGraphQL(tt.args.input); err != nil {
111111
t.Errorf("UnmarshalGraphQL() error = %v", err)
112112
return
@@ -127,7 +127,7 @@ func TestNullFloat_ImplementsUnmarshaler(t *testing.T) {
127127
}()
128128

129129
// assert *NullFloat implements decode.Unmarshaler interface
130-
var _ decode.Unmarshaler = (*NullFloat)(nil)
130+
var _ decode.Unmarshaler = (*graphql.NullFloat)(nil)
131131
}
132132

133133
func TestNullFloat_UnmarshalGraphQL(t *testing.T) {
@@ -136,7 +136,7 @@ func TestNullFloat_UnmarshalGraphQL(t *testing.T) {
136136
}
137137

138138
good := float64(1234)
139-
ref := NullFloat{
139+
ref := graphql.NullFloat{
140140
Value: &good,
141141
Set: true,
142142
}
@@ -156,7 +156,7 @@ func TestNullFloat_UnmarshalGraphQL(t *testing.T) {
156156

157157
for _, tt := range tests {
158158
t.Run(tt.name, func(t *testing.T) {
159-
gt := new(NullFloat)
159+
gt := new(graphql.NullFloat)
160160
if err := gt.UnmarshalGraphQL(tt.args.input); err != nil {
161161
if err.Error() != tt.wantErr {
162162
t.Errorf("UnmarshalGraphQL() error = %v, want = %s", err, tt.wantErr)
@@ -173,7 +173,7 @@ func TestNullFloat_UnmarshalGraphQL(t *testing.T) {
173173
tests := []struct {
174174
name string
175175
args args
176-
wantEq NullFloat
176+
wantEq graphql.NullFloat
177177
}{
178178
{
179179
name: "int",
@@ -200,7 +200,7 @@ func TestNullFloat_UnmarshalGraphQL(t *testing.T) {
200200

201201
for _, tt := range tests {
202202
t.Run(tt.name, func(t *testing.T) {
203-
gt := new(NullFloat)
203+
gt := new(graphql.NullFloat)
204204
if err := gt.UnmarshalGraphQL(tt.args.input); err != nil {
205205
t.Errorf("UnmarshalGraphQL() error = %v", err)
206206
return

subscription_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ func (r *helloResolver) Hello() string {
2424
return "Hello world!"
2525
}
2626

27-
var resolverErr = errors.New("resolver error")
28-
var resolverQueryErr = &qerrors.QueryError{Message: "query", ResolverError: resolverErr}
27+
var errResolver = errors.New("resolver error")
28+
var resolverQueryErr = &qerrors.QueryError{Message: "query", ResolverError: errResolver}
2929

3030
type helloSaidResolver struct {
3131
err error
@@ -127,7 +127,7 @@ func TestSchemaSubscribe(t *testing.T) {
127127
helloSaidResolver: &helloSaidResolver{
128128
upstream: closedUpstream(
129129
&helloSaidEventResolver{msg: "Hello world!"},
130-
&helloSaidEventResolver{err: resolverErr},
130+
&helloSaidEventResolver{err: errResolver},
131131
&helloSaidEventResolver{msg: "Hello again!"},
132132
),
133133
},
@@ -153,7 +153,7 @@ func TestSchemaSubscribe(t *testing.T) {
153153
Data: json.RawMessage(`
154154
null
155155
`),
156-
Errors: []*qerrors.QueryError{qerrors.Errorf("%s", resolverErr)},
156+
Errors: []*qerrors.QueryError{qerrors.Errorf("%s", errResolver)},
157157
},
158158
{
159159
Data: json.RawMessage(`
@@ -197,7 +197,7 @@ func TestSchemaSubscribe(t *testing.T) {
197197
{
198198
Name: "subscription_resolver_can_error",
199199
Schema: graphql.MustParseSchema(schema, &rootResolver{
200-
helloSaidResolver: &helloSaidResolver{err: resolverErr},
200+
helloSaidResolver: &helloSaidResolver{err: errResolver},
201201
}),
202202
Query: `
203203
subscription onHelloSaid {
@@ -211,7 +211,7 @@ func TestSchemaSubscribe(t *testing.T) {
211211
Data: json.RawMessage(`
212212
null
213213
`),
214-
Errors: []*qerrors.QueryError{qerrors.Errorf("%s", resolverErr)},
214+
Errors: []*qerrors.QueryError{qerrors.Errorf("%s", errResolver)},
215215
},
216216
},
217217
},
@@ -220,7 +220,7 @@ func TestSchemaSubscribe(t *testing.T) {
220220
Schema: graphql.MustParseSchema(schema, &rootResolver{
221221
helloSaidNullableResolver: &helloSaidNullableResolver{
222222
upstream: closedUpstreamNullable(
223-
&helloSaidNullableEventResolver{err: resolverErr},
223+
&helloSaidNullableEventResolver{err: errResolver},
224224
),
225225
},
226226
}),
@@ -240,14 +240,14 @@ func TestSchemaSubscribe(t *testing.T) {
240240
}
241241
}
242242
`),
243-
Errors: []*qerrors.QueryError{qerrors.Errorf("%s", resolverErr)},
243+
Errors: []*qerrors.QueryError{qerrors.Errorf("%s", errResolver)},
244244
},
245245
},
246246
},
247247
{
248248
Name: "subscription_resolver_can_error_optional_event",
249249
Schema: graphql.MustParseSchema(schema, &rootResolver{
250-
helloSaidNullableResolver: &helloSaidNullableResolver{err: resolverErr},
250+
helloSaidNullableResolver: &helloSaidNullableResolver{err: errResolver},
251251
}),
252252
Query: `
253253
subscription onHelloSaid {
@@ -263,7 +263,7 @@ func TestSchemaSubscribe(t *testing.T) {
263263
"helloSaidNullable": null
264264
}
265265
`),
266-
Errors: []*qerrors.QueryError{qerrors.Errorf("%s", resolverErr)},
266+
Errors: []*qerrors.QueryError{qerrors.Errorf("%s", errResolver)},
267267
},
268268
},
269269
},

time_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"testing"
77
"time"
88

9-
. "github.com/graph-gophers/graphql-go"
9+
"github.com/graph-gophers/graphql-go"
1010
"github.com/graph-gophers/graphql-go/decode"
1111
)
1212

@@ -18,11 +18,11 @@ func TestTime_ImplementsUnmarshaler(t *testing.T) {
1818
}()
1919

2020
// assert *Time implements decode.Unmarshaler interface
21-
var _ decode.Unmarshaler = (*Time)(nil)
21+
var _ decode.Unmarshaler = (*graphql.Time)(nil)
2222
}
2323

2424
func TestTime_ImplementsGraphQLType(t *testing.T) {
25-
gt := &Time{}
25+
gt := &graphql.Time{}
2626

2727
if gt.ImplementsGraphQLType("foobar") {
2828
t.Error("Type *Time must not claim to implement GraphQL type 'foobar'")
@@ -43,7 +43,7 @@ func TestTime_MarshalJSON(t *testing.T) {
4343
return
4444
}
4545

46-
if b2, err = json.Marshal(Time{Time: ref}); err != nil {
46+
if b2, err = json.Marshal(graphql.Time{Time: ref}); err != nil {
4747
t.Errorf("MarshalJSON() error = %v", err)
4848
return
4949
}
@@ -80,7 +80,7 @@ func TestTime_UnmarshalGraphQL(t *testing.T) {
8080

8181
for _, tt := range tests {
8282
t.Run(tt.name, func(t *testing.T) {
83-
gt := new(Time)
83+
gt := &graphql.Time{}
8484
if err := gt.UnmarshalGraphQL(tt.args.input); err != nil {
8585
if err.Error() != tt.wantErr {
8686
t.Errorf("UnmarshalGraphQL() error = %v, want = %s", err, tt.wantErr)
@@ -152,7 +152,7 @@ func TestTime_UnmarshalGraphQL(t *testing.T) {
152152

153153
for _, tt := range tests {
154154
t.Run(tt.name, func(t *testing.T) {
155-
gt := &Time{}
155+
gt := &graphql.Time{}
156156
if err := gt.UnmarshalGraphQL(tt.args.input); err != nil {
157157
t.Errorf("UnmarshalGraphQL() error = %v", err)
158158
return

0 commit comments

Comments
 (0)