Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
shijiesheng committed Oct 21, 2024
1 parent 0cbbfa1 commit 0886551
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 50 deletions.
96 changes: 48 additions & 48 deletions tools/cli/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ type (
}

testcase struct {
name string
name string
command string
err string
mock func()
err string
mock func()
}
)

Expand Down Expand Up @@ -476,21 +476,21 @@ func (s *cliAppSuite) TestDescribeWorkflow() {
func (s *cliAppSuite) TestQueryWorkflow() {
s.testcaseHelper([]testcase{
{
name: "happy",
name: "happy",
command: `cadence --do test-domain wf query -w wid -qt query-type-test`,
err: "",
mock: func () {
err: "",
mock: func() {
resp := &types.QueryWorkflowResponse{
QueryResult: []byte("query-result"),
}
s.serverFrontendClient.EXPECT().QueryWorkflow(gomock.Any(), gomock.Any()).Return(resp, nil)
},
},
{
name: "query with reject not_open",
name: "query with reject not_open",
command: `cadence --do test-domain wf query -w wid -qt query-type-test --query_reject_condition not_open`,
err: "",
mock: func () {
err: "",
mock: func() {
resp := &types.QueryWorkflowResponse{
QueryResult: []byte("query-result"),
}
Expand All @@ -509,10 +509,10 @@ func (s *cliAppSuite) TestQueryWorkflow() {
},
},
{
name: "query with reject not_completed_cleanly",
name: "query with reject not_completed_cleanly",
command: `cadence --do test-domain wf query -w wid -qt query-type-test --query_reject_condition not_completed_cleanly`,
err: "",
mock: func () {
err: "",
mock: func() {
resp := &types.QueryWorkflowResponse{
QueryResult: []byte("query-result"),
}
Expand All @@ -531,15 +531,15 @@ func (s *cliAppSuite) TestQueryWorkflow() {
},
},
{
name: "query with unknown reject",
name: "query with unknown reject",
command: `cadence --do test-domain wf query -w wid -qt query-type-test --query_reject_condition unknown`,
err: "invalid reject condition",
err: "invalid reject condition",
},
{
name: "query with eventual consistency",
name: "query with eventual consistency",
command: `cadence --do test-domain wf query -w wid -qt query-type-test --query_consistency_level eventual`,
err: "",
mock: func () {
err: "",
mock: func() {
resp := &types.QueryWorkflowResponse{
QueryResult: []byte("query-result"),
}
Expand All @@ -558,10 +558,10 @@ func (s *cliAppSuite) TestQueryWorkflow() {
},
},
{
name: "query with strong consistency",
name: "query with strong consistency",
command: `cadence --do test-domain wf query -w wid -qt query-type-test --query_consistency_level strong`,
err: "",
mock: func () {
err: "",
mock: func() {
resp := &types.QueryWorkflowResponse{
QueryResult: []byte("query-result"),
}
Expand All @@ -580,22 +580,22 @@ func (s *cliAppSuite) TestQueryWorkflow() {
},
},
{
name: "query with invalid consistency",
name: "query with invalid consistency",
command: `cadence --do test-domain wf query -w wid -qt query-type-test --query_consistency_level invalid`,
err: "invalid query consistency level",
err: "invalid query consistency level",
},
{
name: "failed",
name: "failed",
command: `cadence --do test-domain wf query -w wid -qt query-type-test`,
err: "some error",
mock: func () {
err: "some error",
mock: func() {
s.serverFrontendClient.EXPECT().QueryWorkflow(gomock.Any(), gomock.Any()).Return(nil, fmt.Errorf("some error"))
},
},
{
name: "missing flags",
name: "missing flags",
command: "cadence wf query",
err: "Required flag not found",
err: "Required flag not found",
},
})
}
Expand Down Expand Up @@ -651,9 +651,9 @@ var (
func (s *cliAppSuite) TestListAllWorkflow() {
s.testcaseHelper([]testcase{
{
name: "happy",
name: "happy",
command: `cadence --do test-domain wf listall`,
mock: func () {
mock: func() {
countWorkflowResp := &types.CountWorkflowExecutionsResponse{}
s.serverFrontendClient.EXPECT().CountWorkflowExecutions(gomock.Any(), gomock.Any()).Return(countWorkflowResp, nil)
s.serverFrontendClient.EXPECT().ListClosedWorkflowExecutions(gomock.Any(), gomock.Any()).Return(listClosedWorkflowExecutionsResponse, nil)
Expand All @@ -665,9 +665,9 @@ func (s *cliAppSuite) TestListAllWorkflow() {
func (s *cliAppSuite) TestScanAllWorkflow() {
s.testcaseHelper([]testcase{
{
name: "happy",
name: "happy",
command: `cadence --do test-domain wf scanall`,
mock: func () {
mock: func() {
s.serverFrontendClient.EXPECT().ScanWorkflowExecutions(gomock.Any(), gomock.Any()).Return(&types.ListWorkflowExecutionsResponse{}, nil)
},
},
Expand All @@ -677,10 +677,10 @@ func (s *cliAppSuite) TestScanAllWorkflow() {
func (s *cliAppSuite) TestResetWorkflow() {
s.testcaseHelper([]testcase{
{
name: "happy",
name: "happy",
command: `cadence --do test-domain wf reset -w wid -r rid -reason test-reason --event_id 1`,
err: "",
mock: func () {
err: "",
mock: func() {
resp := &types.ResetWorkflowExecutionResponse{RunID: uuid.New()}
s.serverFrontendClient.EXPECT().ResetWorkflowExecution(gomock.Any(), gomock.Any()).Return(resp, nil)
},
Expand Down Expand Up @@ -1061,36 +1061,36 @@ func (s *cliAppSuite) TestParseBool() {
func (s *cliAppSuite) TestSignalWithStartWorkflowExecution() {
s.testcaseHelper([]testcase{
{
name: "happy",
name: "happy",
command: `cadence --do test-domain wf signalwithstart --et 100 --workflow_type sometype --tasklist tasklist -w wid -n signal-name --signal_input []`,
err: "",
mock: func () {
err: "",
mock: func() {
s.serverFrontendClient.EXPECT().SignalWithStartWorkflowExecution(gomock.Any(), gomock.Any()).Return(&types.StartWorkflowExecutionResponse{}, nil)
},
},
{
name: "failed",
name: "failed",
command: `cadence --do test-domain wf signalwithstart --et 100 --workflow_type sometype --tasklist tasklist -w wid -n signal-name --signal_input []`,
err: "some error",
mock: func () {
err: "some error",
mock: func() {
s.serverFrontendClient.EXPECT().SignalWithStartWorkflowExecution(gomock.Any(), gomock.Any()).Return(nil, fmt.Errorf("some error"))
},
},
{
name: "missing flags",
name: "missing flags",
command: "cadence wf signalwithstart",
err: "Required flag not found",
err: "Required flag not found",
},
})
}

func (s *cliAppSuite) TestCompleteActivity() {
s.testcaseHelper([]testcase{
{
name: "happy",
name: "happy",
command: `cadence --do test-domain wf activity complete -w wid -r rid -aid 3 -result result --identity tester`,
err: "",
mock: func () {
err: "",
mock: func() {
s.serverFrontendClient.EXPECT().RespondActivityTaskCompletedByID(gomock.Any(), gomock.Any()).Return(nil)
},
},
Expand All @@ -1100,10 +1100,10 @@ func (s *cliAppSuite) TestCompleteActivity() {
func (s *cliAppSuite) TestFailActivity() {
s.testcaseHelper([]testcase{
{
name: "happy",
name: "happy",
command: `cadence --do test-domain wf activity fail -w wid -r rid -aid 3 --reason somereason --detail somedetail --identity tester`,
err: "",
mock: func () {
err: "",
mock: func() {
s.serverFrontendClient.EXPECT().RespondActivityTaskFailedByID(gomock.Any(), gomock.Any()).Return(nil)
},
},
Expand Down
4 changes: 2 additions & 2 deletions tools/cli/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ func Test_JSONHistorySerializer(t *testing.T) {
h := &types.History{
Events: []*types.HistoryEvent{
{
ID: 1,
ID: 1,
Version: 1,
EventType: types.EventTypeWorkflowExecutionStarted.Ptr(),
},
{
ID: 2,
ID: 2,
Version: 1,
EventType: types.EventTypeDecisionTaskScheduled.Ptr(),
},
Expand Down

0 comments on commit 0886551

Please sign in to comment.