Skip to content

Commit 05a0684

Browse files
committed
refactor result functions for testing
1 parent fa9e3e8 commit 05a0684

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

err2_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package err2_test
22

33
import (
4+
"errors"
45
"fmt"
56
"io"
67
"os"
@@ -14,18 +15,17 @@ import (
1415

1516
const errStringInThrow = "this is an ERROR"
1617

17-
func throw() (string, error) {
18-
return "", fmt.Errorf(errStringInThrow)
19-
}
18+
var (
19+
errToTest = errors.New(errStringInThrow)
20+
)
21+
22+
func throw() (string, error) { return "", errToTest }
23+
func noThrow() (string, error) { return "test", nil }
24+
func noErr() error { return nil }
2025

2126
func twoStrNoThrow() (string, string, error) { return "test", "test", nil }
2227
func intStrNoThrow() (int, string, error) { return 1, "test", nil }
2328
func boolIntStrNoThrow() (bool, int, string, error) { return true, 1, "test", nil }
24-
func noThrow() (string, error) { return "test", nil }
25-
26-
func noErr() error {
27-
return nil
28-
}
2929

3030
func TestTry_noError(t *testing.T) {
3131
t.Parallel()

0 commit comments

Comments
 (0)