Skip to content

Commit

Permalink
Fix Nil to NoError
Browse files Browse the repository at this point in the history
Signed-off-by: Steve Coffman <[email protected]>
  • Loading branch information
StevenACoffman committed Apr 20, 2022
1 parent bce9c16 commit f3ecd75
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions codegen/testserver/singlefile/directive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ func TestDirectives(t *testing.T) {

err := c.Post(`query { directiveInputNullable(arg: {text:"23",inner:{message:"1"}}) }`, &resp)

require.Nil(t, err)
require.NoError(t, err)
require.Equal(t, "Ok", *resp.DirectiveInputNullable)
})
t.Run("when function inner nullable success", func(t *testing.T) {
Expand All @@ -360,7 +360,7 @@ func TestDirectives(t *testing.T) {

err := c.Post(`query { directiveInputNullable(arg: {text:"23",nullableText:"23",inner:{message:"1"},innerNullable:{message:"success"}}) }`, &resp)

require.Nil(t, err)
require.NoError(t, err)
require.Equal(t, "Ok", *resp.DirectiveInputNullable)
})
t.Run("when arg has directive", func(t *testing.T) {
Expand All @@ -370,7 +370,7 @@ func TestDirectives(t *testing.T) {

err := c.Post(`query { directiveInputType(arg: {id: 1}) }`, &resp)

require.Nil(t, err)
require.NoError(t, err)
require.Equal(t, "Ok", *resp.DirectiveInputType)
})
})
Expand All @@ -386,7 +386,7 @@ func TestDirectives(t *testing.T) {

err := c.Post(`query { directiveObject{ text nullableText order} }`, &resp)

require.Nil(t, err)
require.NoError(t, err)
require.Equal(t, "Ok", resp.DirectiveObject.Text)
require.True(t, resp.DirectiveObject.NullableText == nil)
require.Equal(t, "Query_field", resp.DirectiveObject.Order[0])
Expand All @@ -403,7 +403,7 @@ func TestDirectives(t *testing.T) {

err := c.Post(`query { directiveObjectWithCustomGoModel{ nullableText } }`, &resp)

require.Nil(t, err)
require.NoError(t, err)
require.True(t, resp.DirectiveObjectWithCustomGoModel.NullableText == nil)
})
})
Expand Down Expand Up @@ -437,7 +437,8 @@ func TestDirectives(t *testing.T) {

err := c.WebsocketOnce(`subscription { directiveNullableArg }`, &resp)

require.Nil(t, err)
require.NoError(t, err)
require.NotNil(t, resp.DirectiveNullableArg)
require.Equal(t, "Ok", *resp.DirectiveNullableArg)
})
t.Run("when function success on valid nullable arg directives", func(t *testing.T) {
Expand All @@ -447,7 +448,7 @@ func TestDirectives(t *testing.T) {

err := c.WebsocketOnce(`subscription { directiveNullableArg(arg: 1) }`, &resp)

require.Nil(t, err)
require.NoError(t, err)
require.Equal(t, "Ok", *resp.DirectiveNullableArg)
})
t.Run("when function success", func(t *testing.T) {
Expand All @@ -457,7 +458,7 @@ func TestDirectives(t *testing.T) {

err := c.WebsocketOnce(`subscription { directiveArg(arg: "test") }`, &resp)

require.Nil(t, err)
require.NoError(t, err)
require.Equal(t, "Ok", *resp.DirectiveArg)
})
})
Expand Down

0 comments on commit f3ecd75

Please sign in to comment.