forked from mistifyio/go-zfs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror_test.go
37 lines (33 loc) · 826 Bytes
/
error_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package zfs
import (
"errors"
"fmt"
"testing"
)
func TestError(t *testing.T) {
var tests = []struct {
err error
debug string
stderr string
}{
// Empty error
{nil, "", ""},
// Typical error
{errors.New("exit status foo"), "/sbin/foo bar qux", "command not found"},
// Quoted error
{errors.New("exit status quoted"), "\"/sbin/foo\" bar qux", "\"some\" 'random' `quotes`"},
}
for _, test := range tests {
// Generate error from tests
zErr := Error{
Err: test.err,
Debug: test.debug,
Stderr: test.stderr,
}
// Verify output format is consistent, so that any changes to the
// Error method must be reflected by the test
if str := zErr.Error(); str != fmt.Sprintf("%s: %q => %s", test.err, test.debug, test.stderr) {
t.Fatalf("unexpected Error string: %v", str)
}
}
}