Skip to content

Commit

Permalink
Merge #1694
Browse files Browse the repository at this point in the history
1694: 1683 fail job error message go r=Zelldon a=menski

closes #1683 


Co-authored-by: Sebastian Menski <sebastian.menski@camunda.com>
  • Loading branch information
zeebe-bors[bot] and menski committed Nov 27, 2018
2 parents efeff45 + 83269d8 commit 1461422
Show file tree
Hide file tree
Showing 4 changed files with 181 additions and 129 deletions.
14 changes: 12 additions & 2 deletions clients/go/commands/failJob_command.go
Expand Up @@ -15,7 +15,12 @@ type FailJobCommandStep1 interface {
}

type FailJobCommandStep2 interface {
Retries(int32) DispatchFailJobCommand
Retries(int32) FailJobCommandStep3
}

type FailJobCommandStep3 interface {
DispatchFailJobCommand
ErrorMessage(string) FailJobCommandStep3
}

type FailJobCommand struct {
Expand All @@ -29,11 +34,16 @@ func (cmd *FailJobCommand) JobKey(jobKey int64) FailJobCommandStep2 {
return cmd
}

func (cmd *FailJobCommand) Retries(retries int32) DispatchFailJobCommand {
func (cmd *FailJobCommand) Retries(retries int32) FailJobCommandStep3 {
cmd.request.Retries = retries
return cmd
}

func (cmd *FailJobCommand) ErrorMessage(errorMessage string) FailJobCommandStep3 {
cmd.request.ErrorMessage = errorMessage
return cmd
}

func (cmd *FailJobCommand) Send() (*pb.FailJobResponse, error) {
ctx, cancel := context.WithTimeout(context.Background(), cmd.requestTimeout)
defer cancel()
Expand Down
30 changes: 30 additions & 0 deletions clients/go/commands/failJob_command_test.go
Expand Up @@ -34,3 +34,33 @@ func TestFailJobCommand(t *testing.T) {
t.Errorf("Failed to receive response")
}
}

func TestFailJobCommand_ErrorMessage(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()

client := mock_pb.NewMockGatewayClient(ctrl)

errorMessage := "something went wrong"

request := &pb.FailJobRequest{
JobKey: 123,
Retries: 12,
ErrorMessage: errorMessage,
}
stub := &pb.FailJobResponse{}

client.EXPECT().FailJob(gomock.Any(), &utils.RpcTestMsg{Msg: request}).Return(stub, nil)

command := NewFailJobCommand(client, utils.DefaultTestTimeout)

response, err := command.JobKey(123).Retries(12).ErrorMessage(errorMessage).Send()

if err != nil {
t.Errorf("Failed to send request")
}

if response != stub {
t.Errorf("Failed to receive response")
}
}

0 comments on commit 1461422

Please sign in to comment.