-
Notifications
You must be signed in to change notification settings - Fork 8
/
nop_emitter_test.go
50 lines (39 loc) · 1.01 KB
/
nop_emitter_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
package cff
import (
"context"
"errors"
"testing"
"time"
)
func TestNopEmitter(t *testing.T) {
e := NopEmitter()
ctx := context.Background()
t.Run("flow", func(t *testing.T) {
e := e.FlowInit(&FlowInfo{Name: "foo"})
e.FlowSuccess(ctx)
e.FlowError(ctx, errors.New("great sadness"))
e.FlowDone(ctx, 3*time.Second)
})
t.Run("parallel", func(t *testing.T) {
e := e.ParallelInit(&ParallelInfo{Name: "foo"})
e.ParallelSuccess(ctx)
e.ParallelError(ctx, errors.New("great sadness"))
e.ParallelDone(ctx, 3*time.Second)
})
t.Run("task", func(t *testing.T) {
e := e.TaskInit(
&TaskInfo{Name: "foo"},
&DirectiveInfo{
Name: "bar",
Directive: FlowDirective,
},
)
e.TaskSuccess(ctx)
e.TaskError(ctx, errors.New("great sadness"))
e.TaskErrorRecovered(ctx, errors.New("not that bad"))
e.TaskSkipped(ctx, errors.New("something went wrong"))
e.TaskPanic(ctx, "you found a bug")
e.TaskPanicRecovered(ctx, "you found a bug that wasn't that bad")
e.TaskDone(ctx, time.Second)
})
}