-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy patherrors_test.go
39 lines (31 loc) · 874 Bytes
/
errors_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
package schema
import (
"errors"
"testing"
)
func TestNewErrSchemaValidationEmpty(t *testing.T) {
er := NewErrSchemaValidation(nil)
// test empty string
if str := er.Error(); str != "" {
t.Errorf("invalid error string, received '%v' expected ''", str)
}
}
func TestNewErrSchemaValidationTwoErrors(t *testing.T) {
var arr = []string{
"error 1",
"error 2",
}
var errorsStr string = "error 1; error 2"
er := NewErrSchemaValidation(arr)
// test empty string
if str := er.Error(); str != errorsStr {
t.Errorf("invalid error string, received '%v' expected '%v'", str, errorsStr)
}
}
func TestNewErrCannotBuildSchema(t *testing.T) {
er := NewErrCannotBuildSchema(errors.New("test str"))
refVal := `Cannot build schema: test str`
if str := er.Error(); str != refVal {
t.Errorf("invalid error string, received '%v' expected '%v'", str, refVal)
}
}