Skip to content

Commit 857c948

Browse files
committed
Fix unreachable code issue
1 parent 9614af9 commit 857c948

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

extensions_test.go

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ func tinit(t *testing.T) graphql.Schema {
3535
func TestExtensionInitPanic(t *testing.T) {
3636
ext := newtestExt("testExt")
3737
ext.initFn = func(ctx context.Context, p *graphql.Params) context.Context {
38-
panic(errors.New("test error"))
38+
if true {
39+
panic(errors.New("test error"))
40+
}
3941
return ctx
4042
}
4143

@@ -62,7 +64,9 @@ func TestExtensionInitPanic(t *testing.T) {
6264
func TestExtensionParseDidStartPanic(t *testing.T) {
6365
ext := newtestExt("testExt")
6466
ext.parseDidStartFn = func(ctx context.Context) (context.Context, graphql.ParseFinishFunc) {
65-
panic(errors.New("test error"))
67+
if true {
68+
panic(errors.New("test error"))
69+
}
6670
return ctx, func(err error) {
6771

6872
}
@@ -119,7 +123,9 @@ func TestExtensionParseFinishFuncPanic(t *testing.T) {
119123
func TestExtensionValidationDidStartPanic(t *testing.T) {
120124
ext := newtestExt("testExt")
121125
ext.validationDidStartFn = func(ctx context.Context) (context.Context, graphql.ValidationFinishFunc) {
122-
panic(errors.New("test error"))
126+
if true {
127+
panic(errors.New("test error"))
128+
}
123129
return ctx, func([]gqlerrors.FormattedError) {
124130

125131
}
@@ -176,7 +182,9 @@ func TestExtensionValidationFinishFuncPanic(t *testing.T) {
176182
func TestExtensionExecutionDidStartPanic(t *testing.T) {
177183
ext := newtestExt("testExt")
178184
ext.executionDidStartFn = func(ctx context.Context) (context.Context, graphql.ExecutionFinishFunc) {
179-
panic(errors.New("test error"))
185+
if true {
186+
panic(errors.New("test error"))
187+
}
180188
return ctx, func(r *graphql.Result) {
181189

182190
}
@@ -236,7 +244,9 @@ func TestExtensionExecutionFinishFuncPanic(t *testing.T) {
236244
func TestExtensionResolveFieldDidStartPanic(t *testing.T) {
237245
ext := newtestExt("testExt")
238246
ext.resolveFieldDidStartFn = func(ctx context.Context, i *graphql.ResolveInfo) (context.Context, graphql.ResolveFieldFinishFunc) {
239-
panic(errors.New("test error"))
247+
if true {
248+
panic(errors.New("test error"))
249+
}
240250
return ctx, func(v interface{}, err error) {
241251

242252
}
@@ -299,7 +309,9 @@ func TestExtensionResolveFieldFinishFuncPanic(t *testing.T) {
299309
func TestExtensionGetResultPanic(t *testing.T) {
300310
ext := newtestExt("testExt")
301311
ext.getResultFn = func(context.Context) interface{} {
302-
panic(errors.New("test error"))
312+
if true {
313+
panic(errors.New("test error"))
314+
}
303315
return nil
304316
}
305317
ext.hasResultFn = func() bool {

0 commit comments

Comments
 (0)