diff --git a/common/persistence/elasticsearch/es_visibility_store_test.go b/common/persistence/elasticsearch/es_visibility_store_test.go index bbb43562879..07de2b2bce6 100644 --- a/common/persistence/elasticsearch/es_visibility_store_test.go +++ b/common/persistence/elasticsearch/es_visibility_store_test.go @@ -305,7 +305,7 @@ func (s *ESVisibilitySuite) TestListOpenWorkflowExecutions() { _, err = s.visibilityStore.ListOpenWorkflowExecutions(ctx, testRequest) s.Error(err) s.ErrorAs(err, new(*types.InternalServiceError)) - s.True(strings.Contains(err.Error(), "ListOpenWorkflowExecutions failed")) + s.ErrorContains(err, "ListOpenWorkflowExecutions failed") } func (s *ESVisibilitySuite) TestListClosedWorkflowExecutions() { @@ -325,7 +325,7 @@ func (s *ESVisibilitySuite) TestListClosedWorkflowExecutions() { _, err = s.visibilityStore.ListClosedWorkflowExecutions(ctx, testRequest) s.Error(err) s.ErrorAs(err, new(*types.InternalServiceError)) - s.True(strings.Contains(err.Error(), "ListClosedWorkflowExecutions failed")) + s.ErrorContains(err, "ListClosedWorkflowExecutions failed") } func (s *ESVisibilitySuite) TestListOpenWorkflowExecutionsByType() { @@ -353,7 +353,7 @@ func (s *ESVisibilitySuite) TestListOpenWorkflowExecutionsByType() { _, err = s.visibilityStore.ListOpenWorkflowExecutionsByType(ctx, request) s.Error(err) s.ErrorAs(err, new(*types.InternalServiceError)) - s.True(strings.Contains(err.Error(), "ListOpenWorkflowExecutionsByType failed")) + s.ErrorContains(err, "ListOpenWorkflowExecutionsByType failed") } func (s *ESVisibilitySuite) TestListAllWorkflowExecutions() { @@ -389,7 +389,7 @@ func (s *ESVisibilitySuite) TestListClosedWorkflowExecutionsByType() { _, err = s.visibilityStore.ListClosedWorkflowExecutionsByType(ctx, request) s.Error(err) s.ErrorAs(err, new(*types.InternalServiceError)) - s.True(strings.Contains(err.Error(), "ListClosedWorkflowExecutionsByType failed")) + s.ErrorContains(err, "ListClosedWorkflowExecutionsByType failed") } func (s *ESVisibilitySuite) TestListOpenWorkflowExecutionsByWorkflowID() { @@ -418,7 +418,7 @@ func (s *ESVisibilitySuite) TestListOpenWorkflowExecutionsByWorkflowID() { _, err = s.visibilityStore.ListOpenWorkflowExecutionsByWorkflowID(ctx, request) s.Error(err) s.ErrorAs(err, new(*types.InternalServiceError)) - s.True(strings.Contains(err.Error(), "ListOpenWorkflowExecutionsByWorkflowID failed")) + s.ErrorContains(err, "ListOpenWorkflowExecutionsByWorkflowID failed") } func (s *ESVisibilitySuite) TestListClosedWorkflowExecutionsByWorkflowID() { @@ -447,7 +447,7 @@ func (s *ESVisibilitySuite) TestListClosedWorkflowExecutionsByWorkflowID() { _, err = s.visibilityStore.ListClosedWorkflowExecutionsByWorkflowID(ctx, request) s.Error(err) s.ErrorAs(err, new(*types.InternalServiceError)) - s.True(strings.Contains(err.Error(), "ListClosedWorkflowExecutionsByWorkflowID failed")) + s.ErrorContains(err, "ListClosedWorkflowExecutionsByWorkflowID failed") } func (s *ESVisibilitySuite) TestListClosedWorkflowExecutionsByStatus() { @@ -477,7 +477,7 @@ func (s *ESVisibilitySuite) TestListClosedWorkflowExecutionsByStatus() { _, err = s.visibilityStore.ListClosedWorkflowExecutionsByStatus(ctx, request) s.Error(err) s.ErrorAs(err, new(*types.InternalServiceError)) - s.True(strings.Contains(err.Error(), "ListClosedWorkflowExecutionsByStatus failed")) + s.ErrorContains(err, "ListClosedWorkflowExecutionsByStatus failed") } func (s *ESVisibilitySuite) TestGetNextPageToken() { @@ -511,7 +511,7 @@ func (s *ESVisibilitySuite) TestDeserializePageToken() { s.Nil(result) var typedError *types.BadRequestError s.ErrorAs(err, &typedError) - s.True(strings.Contains(typedError.Error(), "unable to deserialize page token")) + s.ErrorContains(typedError, "unable to deserialize page token") token = &es.ElasticVisibilityPageToken{SortValue: int64(64), TieBreaker: "unique"} data, _ = es.SerializePageToken(token) @@ -810,13 +810,13 @@ func (s *ESVisibilitySuite) TestListWorkflowExecutions() { _, err = s.visibilityStore.ListWorkflowExecutions(ctx, request) s.Error(err) s.ErrorAs(err, new(*types.InternalServiceError)) - s.True(strings.Contains(err.Error(), "ListWorkflowExecutions failed")) + s.ErrorContains(err, "ListWorkflowExecutions failed") request.Query = `invalid query` _, err = s.visibilityStore.ListWorkflowExecutions(context.Background(), request) s.Error(err) s.ErrorAs(err, new(*types.BadRequestError)) - s.True(strings.Contains(err.Error(), "Error when parse query")) + s.ErrorContains(err, "Error when parse query") } func (s *ESVisibilitySuite) TestScanWorkflowExecutions() { @@ -844,7 +844,7 @@ func (s *ESVisibilitySuite) TestScanWorkflowExecutions() { _, err = s.visibilityStore.ScanWorkflowExecutions(ctx, request) s.Error(err) s.ErrorAs(err, new(*types.BadRequestError)) - s.True(strings.Contains(err.Error(), "Error when parse query")) + s.ErrorContains(err, "Error when parse query") // test internal error request.Query = `CloseStatus = 5` @@ -852,7 +852,7 @@ func (s *ESVisibilitySuite) TestScanWorkflowExecutions() { _, err = s.visibilityStore.ScanWorkflowExecutions(ctx, request) s.Error(err) s.ErrorAs(err, new(*types.InternalServiceError)) - s.True(strings.Contains(err.Error(), "ScanWorkflowExecutions failed")) + s.ErrorContains(err, "ScanWorkflowExecutions failed") } func (s *ESVisibilitySuite) TestCountWorkflowExecutions() { @@ -880,14 +880,14 @@ func (s *ESVisibilitySuite) TestCountWorkflowExecutions() { _, err = s.visibilityStore.CountWorkflowExecutions(ctx, request) s.Error(err) s.ErrorAs(err, new(*types.InternalServiceError)) - s.True(strings.Contains(err.Error(), "CountWorkflowExecutions failed")) + s.ErrorContains(err, "CountWorkflowExecutions failed") // test bad request request.Query = `invalid query` _, err = s.visibilityStore.CountWorkflowExecutions(ctx, request) s.Error(err) s.ErrorAs(err, new(*types.BadRequestError)) - s.True(strings.Contains(err.Error(), "Error when parse query")) + s.ErrorContains(err, "Error when parse query") } func (s *ESVisibilitySuite) TestTimeProcessFunc() { diff --git a/host/signal_workflow_test.go b/host/signal_workflow_test.go index b9834c5d91c..f581351d2f5 100644 --- a/host/signal_workflow_test.go +++ b/host/signal_workflow_test.go @@ -26,7 +26,6 @@ import ( "encoding/binary" "fmt" "strconv" - "strings" "time" "github.com/pborman/uuid" @@ -1576,8 +1575,7 @@ func (s *IntegrationSuite) TestSignalWithStartWorkflow_IDReusePolicy() { s.Error(err) var alreadyStartedErr *types.WorkflowExecutionAlreadyStartedError s.ErrorAs(err, &alreadyStartedErr) - errMsg := alreadyStartedErr.GetMessage() - s.True(strings.Contains(errMsg, "reject duplicate workflow ID")) + s.ErrorContains(alreadyStartedErr, "reject duplicate workflow ID") // test policy WorkflowIDReusePolicyAllowDuplicateFailedOnly wfIDReusePolicy = types.WorkflowIDReusePolicyAllowDuplicateFailedOnly @@ -1588,8 +1586,7 @@ func (s *IntegrationSuite) TestSignalWithStartWorkflow_IDReusePolicy() { s.Nil(resp) s.Error(err) s.ErrorAs(err, &alreadyStartedErr) - errMsg = alreadyStartedErr.GetMessage() - s.True(strings.Contains(errMsg, "allow duplicate workflow ID if last run failed")) + s.ErrorContains(alreadyStartedErr, "allow duplicate workflow ID if last run failed") // test policy WorkflowIDReusePolicyAllowDuplicate wfIDReusePolicy = types.WorkflowIDReusePolicyAllowDuplicate