-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinspection_test.go
50 lines (42 loc) · 1.22 KB
/
inspection_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
38
39
40
41
42
43
44
45
46
47
48
49
50
package errors
import "testing"
func TestUnWrap(t *testing.T) {
const op = Op("TestKindOf")
e0 := Str("tcp connection dropped")
e1 := New("network unreachable", IO, e0)
e2 := WithMessage(e1, "annotation0")
e3 := WithOpf(e2, op, "annotation1")
want := e1
if got := Unwrap(e3); got != want {
t.Errorf("KindOf() = %v, want %v", got, want)
}
// add second level kind
e4 := WithKind(e3, Permission, "permission error")
e5 := WithMessage(e4, "annotation")
want = e4
if got := Unwrap(e5); got != want {
t.Errorf("KindOf() = %v, want %v", got, want)
}
}
func TestKindOf(t *testing.T) {
const op = Op("TestKindOf")
e0 := Str("tcp connection dropped")
e1 := New("network unreachable", IO, e0)
e2 := WithMessage(e1, "annotation0")
e3 := WithOpf(e2, op, "annotation1")
want := IO
if got := KindOf(e3); got != want {
t.Errorf("KindOf() = %v, want %v", got, want)
}
// add second level kind
e4 := WithKind(e3, Permission, "permission error")
e5 := WithMessage(e4, "annotation")
want = Permission
if got := KindOf(e5); got != want {
t.Errorf("KindOf() = %v, want %v", got, want)
}
want = Internal
if got := KindOf(e0); got != want {
t.Errorf("when Error was not present: KindOf() = %v, want %v", got, want)
}
}