-
Notifications
You must be signed in to change notification settings - Fork 0
/
all_test.go
49 lines (41 loc) · 858 Bytes
/
all_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
package asynks
import (
"errors"
"testing"
"github.com/golang-must/must"
)
func TestAll(t *testing.T) {
tasks := []TaskAll{
func() (interface{}, error) {
return 1, nil
},
func() (interface{}, error) {
return 2, nil
},
func() (interface{}, error) {
return 3, nil
},
}
tasksWithErrors := []TaskAll{
func() (interface{}, error) {
return nil, errors.New("don't cry")
},
func() (interface{}, error) {
return nil, errors.New("don't cry")
},
func() (interface{}, error) {
return nil, errors.New("don't cry")
},
}
t.Run("data length equals task length", func(t *testing.T) {
data, _ := All(tasks)
must := must.New(t)
must.Equal(3, len(data))
})
t.Run("task error produce error", func(t *testing.T) {
must := must.New(t)
data, err := All(tasksWithErrors)
must.Nil(data)
must.NotNil(err)
})
}