From 05a068463751a28d7db12eebd8fb558e2ad0470d Mon Sep 17 00:00:00 2001 From: Harri Lainio Date: Sat, 17 Aug 2024 16:50:34 +0300 Subject: [PATCH] refactor result functions for testing --- err2_test.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/err2_test.go b/err2_test.go index 19a87db..fde4c48 100644 --- a/err2_test.go +++ b/err2_test.go @@ -1,6 +1,7 @@ package err2_test import ( + "errors" "fmt" "io" "os" @@ -14,18 +15,17 @@ import ( const errStringInThrow = "this is an ERROR" -func throw() (string, error) { - return "", fmt.Errorf(errStringInThrow) -} +var ( + errToTest = errors.New(errStringInThrow) +) + +func throw() (string, error) { return "", errToTest } +func noThrow() (string, error) { return "test", nil } +func noErr() error { return nil } func twoStrNoThrow() (string, string, error) { return "test", "test", nil } func intStrNoThrow() (int, string, error) { return 1, "test", nil } func boolIntStrNoThrow() (bool, int, string, error) { return true, 1, "test", nil } -func noThrow() (string, error) { return "test", nil } - -func noErr() error { - return nil -} func TestTry_noError(t *testing.T) { t.Parallel()