Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix remove checkNilCase test helper function #504

Merged
merged 1 commit into from
Mar 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions internal/schema/schema_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,6 @@ func TestParseInputDef(t *testing.T) {
func compareDirectiveDefinitions(t *testing.T, expected *types.DirectiveDefinition, actual *types.DirectiveDefinition) {
t.Helper()

checkNilCase(t, expected, actual)

if expected.Name != actual.Name {
t.Fatalf("wrong DirectiveDefinition name: want %q, got %q", expected.Name, actual.Name)
}
Expand All @@ -267,8 +265,6 @@ func compareDirectiveDefinitions(t *testing.T, expected *types.DirectiveDefiniti
func compareInputObjectTypeDefinition(t *testing.T, expected, actual *types.InputObject) {
t.Helper()

checkNilCase(t, expected, actual)

if expected.Name != actual.Name {
t.Fatalf("wrong InputObject name: want %q, got %q", expected.Name, actual.Name)
}
Expand All @@ -279,8 +275,6 @@ func compareInputObjectTypeDefinition(t *testing.T, expected, actual *types.Inpu
func compareEnumTypeDefs(t *testing.T, expected, actual *types.EnumTypeDefinition) {
t.Helper()

checkNilCase(t, expected, actual)

if expected.Name != actual.Name {
t.Fatalf("wrong EnumTypeDefinition name: want %q, got %q", expected.Name, actual.Name)
}
Expand Down Expand Up @@ -327,8 +321,6 @@ func compareErrors(t *testing.T, expected, actual *errors.QueryError) {
func compareInterfaces(t *testing.T, expected, actual *types.InterfaceTypeDefinition) {
t.Helper()

checkNilCase(t, expected, actual)

if expected.Name != actual.Name {
t.Errorf("wrong interface name: want %q, got %q", expected.Name, actual.Name)
}
Expand All @@ -349,8 +341,6 @@ func compareInterfaces(t *testing.T, expected, actual *types.InterfaceTypeDefini
func compareUnions(t *testing.T, expected, actual *types.Union) {
t.Helper()

checkNilCase(t, expected, actual)

if expected.Name != actual.Name {
t.Errorf("wrong object name: want %q, got %q", expected.Name, actual.Name)
}
Expand All @@ -363,8 +353,6 @@ func compareUnions(t *testing.T, expected, actual *types.Union) {
func compareObjects(t *testing.T, expected, actual *types.ObjectTypeDefinition) {
t.Helper()

checkNilCase(t, expected, actual)

if expected.Name != actual.Name {
t.Errorf("wrong object name: want %q, got %q", expected.Name, actual.Name)
}
Expand All @@ -385,19 +373,6 @@ func compareObjects(t *testing.T, expected, actual *types.ObjectTypeDefinition)
}
}

func checkNilCase(t *testing.T, a, b interface{}) {
t.Helper()

switch {
case a == nil && a == b:
return
case a == nil && b != nil:
t.Fatalf("wanted nil, got an unexpected result: %#v", b)
case a != nil && b == nil:
t.Fatalf("wanted non-nil result, got nil")
}
}

func setup(t *testing.T, def string) *common.Lexer {
t.Helper()

Expand Down