forked from rocketlaunchr/dataframe-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror_collection_test.go
50 lines (38 loc) · 976 Bytes
/
error_collection_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
// Copyright 2018-20 PJ Engineering and Business Solutions Pty. Ltd. All rights reserved.
package dataframe
import (
"errors"
"testing"
)
var (
ErrTestA = errors.New("test A error")
ErrTestB = errors.New("test B error")
ErrTestC = errors.New("test C error")
)
func TestErrorCollection(t *testing.T) {
ec := NewErrorCollection()
// Issue: https://github.com/golang/go/issues/39167
// if !errors.Is(ec, nil) {
// t.Errorf("errors.Is(ec, nil) should return true")
// }
ec.AddError(ErrTestA)
ec.AddError(ErrTestB)
// Test nil
isNil := ec.IsNil()
if isNil == true {
t.Errorf("err collection should not be nil")
}
// Test items in Collection
resA := ec.Is(ErrTestA)
resB := ec.Is(ErrTestB)
resC := ec.Is(ErrTestC)
if resA == false {
t.Errorf("err collection should contain ErrTestA")
}
if resB == false {
t.Errorf("err collection should contain ErrTestB")
}
if resC == true {
t.Errorf("err collection should not contain ErrTestC")
}
}