forked from cayleygraph/cayley
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquadwriter_test.go
63 lines (56 loc) · 1.48 KB
/
quadwriter_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
51
52
53
54
55
56
57
58
59
60
61
62
63
package graph
import (
"errors"
"testing"
)
func TestIsQuadExist(t *testing.T) {
tests := []struct {
Err error
Matches bool
}{
{Err: nil, Matches: false},
{Err: errors.New("foo"), Matches: false},
{Err: ErrQuadExists, Matches: true},
{Err: &DeltaError{Err: errors.New("foo")}, Matches: false},
{Err: &DeltaError{Err: ErrQuadExists}, Matches: true},
}
for i, test := range tests {
if match := IsQuadExist(test.Err); test.Matches != match {
t.Errorf("%d> unexpected match: %t", i, match)
}
}
}
func TestIsQuadNotExist(t *testing.T) {
tests := []struct {
Err error
Matches bool
}{
{Err: nil, Matches: false},
{Err: errors.New("foo"), Matches: false},
{Err: ErrQuadNotExist, Matches: true},
{Err: &DeltaError{Err: errors.New("foo")}, Matches: false},
{Err: &DeltaError{Err: ErrQuadNotExist}, Matches: true},
}
for i, test := range tests {
if match := IsQuadNotExist(test.Err); test.Matches != match {
t.Errorf("%d> unexpected match: %t", i, match)
}
}
}
func TestIsInvalidAction(t *testing.T) {
tests := []struct {
Err error
Matches bool
}{
{Err: nil, Matches: false},
{Err: errors.New("foo"), Matches: false},
{Err: ErrInvalidAction, Matches: true},
{Err: &DeltaError{Err: errors.New("foo")}, Matches: false},
{Err: &DeltaError{Err: ErrInvalidAction}, Matches: true},
}
for i, test := range tests {
if match := IsInvalidAction(test.Err); test.Matches != match {
t.Errorf("%d> unexpected match: %t", i, match)
}
}
}