-
Notifications
You must be signed in to change notification settings - Fork 490
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add panic handler test, remove redundant "graphql:" prefix
- Loading branch information
1 parent
513af5d
commit c756fe8
Showing
2 changed files
with
25 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package errors | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
) | ||
|
||
func TestDefaultPanicHandler(t *testing.T) { | ||
handler := &DefaultPanicHandler{} | ||
qErr := handler.MakePanicError(context.Background(), "foo") | ||
if qErr == nil { | ||
t.Fatal("Panic error must not be nil") | ||
} | ||
const ( | ||
expectedMessage = "panic occurred: foo" | ||
expectedError = "graphql: " + expectedMessage | ||
) | ||
if qErr.Error() != expectedError { | ||
t.Errorf("Unexpected panic error message: %q != %q", qErr.Error(), expectedError) | ||
} | ||
if qErr.Message != expectedMessage { | ||
t.Errorf("Unexpected panic QueryError.Message: %q != %q", qErr.Message, expectedMessage) | ||
} | ||
} |