-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors_test.go
More file actions
54 lines (46 loc) · 1.26 KB
/
errors_test.go
File metadata and controls
54 lines (46 loc) · 1.26 KB
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
51
52
53
54
package truenas
import (
"errors"
"testing"
)
func TestIsNotFoundError_Nil(t *testing.T) {
if isNotFoundError(nil) {
t.Error("expected false for nil error")
}
}
func TestIsNotFoundError_DoesNotExist(t *testing.T) {
err := errors.New("object with id 42 does not exist")
if !isNotFoundError(err) {
t.Error("expected true for 'does not exist' error")
}
}
func TestIsNotFoundError_ENOENT(t *testing.T) {
err := errors.New("[ENOENT] No such file or directory")
if !isNotFoundError(err) {
t.Error("expected true for '[ENOENT]' error")
}
}
func TestIsNotFoundError_NotFound(t *testing.T) {
err := errors.New("resource not found")
if !isNotFoundError(err) {
t.Error("expected true for 'not found' error")
}
}
func TestIsNotFoundError_NoSuchInstance(t *testing.T) {
err := errors.New("no such instance")
if !isNotFoundError(err) {
t.Error("expected true for 'no such instance' error")
}
}
func TestIsNotFoundError_Unrelated(t *testing.T) {
err := errors.New("connection refused")
if isNotFoundError(err) {
t.Error("expected false for unrelated error")
}
}
func TestIsNotFoundError_BothPatterns(t *testing.T) {
err := errors.New("resource does not exist [ENOENT]")
if !isNotFoundError(err) {
t.Error("expected true when both patterns are present")
}
}