Debian Codegraph @

error_test.go

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