Skip to content

Commit

Permalink
Add getter-based assertions to pointer test (after rebase)
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminjkraft committed Aug 25, 2021
1 parent dfb8cde commit e0eaca5
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion internal/integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,20 @@ func TestInterfaceListPointerField(t *testing.T) {

require.Len(t, resp.Beings, 3)

// Check fields both via interface and via type-assertion:
assert.Equal(t, "User", (*resp.Beings[0]).GetTypename())
assert.Equal(t, "1", (*resp.Beings[0]).GetId())
assert.Equal(t, "Yours Truly", (*resp.Beings[0]).GetName())

user, ok := (*resp.Beings[0]).(*queryWithInterfaceListPointerFieldBeingsUser)
require.Truef(t, ok, "got %T, not User", resp.Beings[0])
require.Truef(t, ok, "got %T, not User", (*resp.Beings[0]))
assert.Equal(t, "1", user.Id)
assert.Equal(t, "Yours Truly", user.Name)

assert.Equal(t, "Animal", (*resp.Beings[1]).GetTypename())
assert.Equal(t, "3", (*resp.Beings[1]).GetId())
assert.Equal(t, "Fido", (*resp.Beings[1]).GetName())

animal, ok := (*resp.Beings[1]).(*queryWithInterfaceListPointerFieldBeingsAnimal)
require.Truef(t, ok, "got %T, not Animal", resp.Beings[1])
assert.Equal(t, "3", animal.Id)
Expand Down

0 comments on commit e0eaca5

Please sign in to comment.