From e0eaca56032fe09ad2f628604aec66cdbb86b877 Mon Sep 17 00:00:00 2001 From: Ben Kraft Date: Wed, 25 Aug 2021 11:47:13 -0700 Subject: [PATCH] Add getter-based assertions to pointer test (after rebase) --- internal/integration/integration_test.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/internal/integration/integration_test.go b/internal/integration/integration_test.go index cb94ce76..b759ef32 100644 --- a/internal/integration/integration_test.go +++ b/internal/integration/integration_test.go @@ -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)