forked from cayleygraph/cayley
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
graph: add Is*(err error) checker tests
- Loading branch information
1 parent
a962c87
commit 13f6e1e
Showing
1 changed file
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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) | ||
} | ||
} | ||
} |