Skip to content

Commit

Permalink
Feat: add default suspend message (#141)
Browse files Browse the repository at this point in the history
Signed-off-by: FogDong <[email protected]>
  • Loading branch information
FogDong authored Feb 27, 2023
1 parent 6da55e8 commit 8eae143
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 3 additions & 0 deletions pkg/providers/workspace/workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ func (h *provider) Suspend(ctx monitorContext.Context, wfCtx wfContext.Context,
var msg string
if v != nil {
msg, _ = v.GetString("message")
if msg == "" {
msg = fmt.Sprintf("Suspended by field %s", v.FieldName())
}
}
if timestamp != "" {
t, err := time.Parse(time.RFC3339, timestamp)
Expand Down
3 changes: 1 addition & 2 deletions pkg/providers/workspace/workspace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,12 @@ func TestProvider_Suspend(t *testing.T) {
act := &mockAction{}
v, err := value.NewValue(`
duration: "1s"
message: "hello suspend"
`, nil, "")
r.NoError(err)
err = p.Suspend(nil, wfCtx, v, act)
r.NoError(err)
r.Equal(act.suspend, true)
r.Equal(act.msg, "hello suspend")
r.Equal(act.msg, "Suspended by field ")
// test second time to check if the suspend is resumed in 1s
err = p.Suspend(nil, wfCtx, v, act)
r.NoError(err)
Expand Down

0 comments on commit 8eae143

Please sign in to comment.