-
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathmap_test.go
More file actions
34 lines (31 loc) · 547 Bytes
/
map_test.go
File metadata and controls
34 lines (31 loc) · 547 Bytes
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
package flowmatic_test
import (
"context"
"errors"
"testing"
"github.com/carlmjohnson/flowmatic"
)
func TestMap(t *testing.T) {
ctx := context.Background()
a := errors.New("a")
b := errors.New("b")
o, errs := flowmatic.Map(ctx, 1, []int{1, 2, 3}, func(_ context.Context, i int) (int, error) {
switch i {
case 1:
return 1, a
case 2:
return 2, b
default:
panic("should be canceled by now!")
}
})
if !errors.Is(errs, a) {
t.Fatal(errs)
}
if errors.Is(errs, b) {
t.Fatal(errs)
}
if o != nil {
t.Fatal(o)
}
}