forked from influxdata/kapacitor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
barrier_test.go
46 lines (44 loc) · 884 Bytes
/
barrier_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
package pipeline
import (
"testing"
"time"
)
func TestBarrierNode_MarshalJSON(t *testing.T) {
type fields struct {
Period time.Duration
Idle time.Duration
Delete bool
}
tests := []struct {
name string
fields fields
want string
wantErr bool
}{
{
name: "all fields set",
fields: fields{
Period: time.Hour,
Idle: time.Minute,
Delete: true,
},
want: `{"typeOf":"barrier","id":"0","delete":true,"period":"1h","idle":"1m"}`,
},
{
name: "only period ",
fields: fields{
Period: time.Hour,
},
want: `{"typeOf":"barrier","id":"0","period":"1h","idle":"0s"}`,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
b := newBarrierNode(StreamEdge)
b.Period = tt.fields.Period
b.Idle = tt.fields.Idle
b.Delete = tt.fields.Delete
MarshalTestHelper(t, b, tt.wantErr, tt.want)
})
}
}