-
Notifications
You must be signed in to change notification settings - Fork 4
/
multierror_test.go
47 lines (32 loc) · 1002 Bytes
/
multierror_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
package multierror
import (
"sync"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestMultiErrorValidation(t *testing.T) {
me := &MultiError{mutex: new(sync.Mutex)}
me.Push("one")
me.Push("two")
res := me.HasError()
assert.Error(t, res, "expected populated multi-error validation to be non-nil")
}
func TestMultiErrorRespresentation(t *testing.T) {
me := &MultiError{mutex: new(sync.Mutex)}
me.Push("one")
me.Push("two")
require.Error(t, me, "no multierror occured")
res := me.Error()
assert.Equal(t, "one, two", res)
}
func TestMultiErrorWithoutErrorsValidationIsNil(t *testing.T) {
me := &MultiError{mutex: new(sync.Mutex)}
err := me.HasError()
assert.NoError(t, err, "expected empty multi-error validation to be nil")
}
func TestMultiErrorRespresentationIsEmpty(t *testing.T) {
me := &MultiError{mutex: new(sync.Mutex)}
res := me.Error()
assert.Empty(t, res, "expected empty multi-error representation to be empty")
}