forked from influxdata/kapacitor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add JSON marshalling support to barrier node
- Loading branch information
1 parent
a18dc67
commit b32962a
Showing
2 changed files
with
104 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package pipeline | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
) | ||
|
||
func TestBarrierNode_MarshalJSON(t *testing.T) { | ||
type fields struct { | ||
Period time.Duration | ||
Idle time.Duration | ||
} | ||
tests := []struct { | ||
name string | ||
fields fields | ||
want string | ||
wantErr bool | ||
}{ | ||
{ | ||
name: "all fields set", | ||
fields: fields{ | ||
Period: time.Hour, | ||
Idle: time.Minute, | ||
}, | ||
want: `{"typeOf":"barrier","id":"0","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 | ||
MarshalTestHelper(t, b, tt.wantErr, tt.want) | ||
}) | ||
} | ||
} |