Skip to content

Commit

Permalink
Add more test checks
Browse files Browse the repository at this point in the history
  • Loading branch information
ychebotarev committed Jan 7, 2025
1 parent 0353241 commit 9920b8b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
14 changes: 13 additions & 1 deletion temporalcli/commands.activity.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,22 @@ func (c *TemporalActivityResetCommand) run(cctx *CommandContext, args []string)
ResetHeartbeat: c.ResetHeartbeats,
}

_, err = cl.WorkflowService().ResetActivityById(cctx, request)
resp, err := cl.WorkflowService().ResetActivityById(cctx, request)
if err != nil {
return fmt.Errorf("unable to reset an Activity: %w", err)
}

resetResponse := struct {
NoWait bool
ResetHeartbeats bool
ServerResponse bool
}{
ServerResponse: resp != nil,
NoWait: c.NoWait,
ResetHeartbeats: c.ResetHeartbeats,
}

_ = cctx.Printer.PrintStructured(resetResponse, printer.StructuredOptions{})

return nil
}
7 changes: 7 additions & 0 deletions temporalcli/commands.activity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"go.temporal.io/api/enums/v1"
"go.temporal.io/api/history/v1"
"go.temporal.io/api/serviceerror"
"go.temporal.io/sdk/client"
)

Expand Down Expand Up @@ -247,6 +248,9 @@ func (s *SharedServerSuite) TestActivityReset() {
)

s.NoError(res.Err)
// make sure we receive a server response
out := res.Stdout.String()
s.ContainsOnSameLine(out, "ServerResponse", "true")

// reset should fail because activity is not found

Expand All @@ -260,6 +264,9 @@ func (s *SharedServerSuite) TestActivityReset() {
)

s.Error(res.Err)
// make sure we receive a NotFound error from the server`
var notFound *serviceerror.NotFound
s.ErrorAs(res.Err, &notFound)
}

// Test helpers
Expand Down

0 comments on commit 9920b8b

Please sign in to comment.