Skip to content

Commit

Permalink
Update integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dandavison committed Dec 3, 2024
1 parent 93ef874 commit 2cf86f4
Showing 1 changed file with 15 additions and 23 deletions.
38 changes: 15 additions & 23 deletions test/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3995,10 +3995,9 @@ func (ts *IntegrationTestSuite) TestUpdateWithStartWorkflow() {

ts.Run("sends update-with-start (no running workflow)", func() {
println(ctx)
startOp, err := ts.client.NewWithStartWorkflowOperation(
startOp := ts.client.NewWithStartWorkflowOperation(
startWorkflowOptions(), ts.workflows.UpdateEntityWorkflow,
)
ts.NoError(err)
updHandle, err := ts.client.UpdateWithStartWorkflow(ctx, client.UpdateWorkflowOptions{
UpdateName: "update",
Args: []any{1},
Expand All @@ -4025,8 +4024,7 @@ func (ts *IntegrationTestSuite) TestUpdateWithStartWorkflow() {
ts.NoError(err)

startOptions.WorkflowIDConflictPolicy = enumspb.WORKFLOW_ID_CONFLICT_POLICY_USE_EXISTING
startOp, err := ts.client.NewWithStartWorkflowOperation(startOptions, ts.workflows.UpdateEntityWorkflow)
ts.NoError(err)
startOp := ts.client.NewWithStartWorkflowOperation(startOptions, ts.workflows.UpdateEntityWorkflow)

updHandle, err := ts.client.UpdateWithStartWorkflow(ctx, client.UpdateWorkflowOptions{
UpdateName: "update",
Expand All @@ -4045,8 +4043,7 @@ func (ts *IntegrationTestSuite) TestUpdateWithStartWorkflow() {
})

ts.Run("sends update-with-start but update is rejected", func() {
startOp, err := ts.client.NewWithStartWorkflowOperation(startWorkflowOptions(), ts.workflows.UpdateEntityWorkflow)
ts.NoError(err)
startOp := ts.client.NewWithStartWorkflowOperation(startWorkflowOptions(), ts.workflows.UpdateEntityWorkflow)

updHandle, err := ts.client.UpdateWithStartWorkflow(ctx, client.UpdateWorkflowOptions{
UpdateName: "update",
Expand All @@ -4066,8 +4063,7 @@ func (ts *IntegrationTestSuite) TestUpdateWithStartWorkflow() {

ts.Run("receives results in separate goroutines", func() {

startOp, err := ts.client.NewWithStartWorkflowOperation(startWorkflowOptions(), ts.workflows.UpdateEntityWorkflow)
ts.NoError(err)
startOp := ts.client.NewWithStartWorkflowOperation(startWorkflowOptions(), ts.workflows.UpdateEntityWorkflow)

done1 := make(chan struct{})
defer func() { <-done1 }()
Expand Down Expand Up @@ -4108,23 +4104,22 @@ func (ts *IntegrationTestSuite) TestUpdateWithStartWorkflow() {
startOptions := startWorkflowOptions()

startOptions.CronSchedule = "invalid!"
startOp, err := ts.client.NewWithStartWorkflowOperation(startOptions, ts.workflows.UpdateEntityWorkflow)
ts.NoError(err)
_, err = ts.client.UpdateWithStartWorkflow(ctx, updateOptions, startOp)
startOp := ts.client.NewWithStartWorkflowOperation(startOptions, ts.workflows.UpdateEntityWorkflow)
_, err := ts.client.UpdateWithStartWorkflow(ctx, updateOptions, startOp)
ts.Error(err)

startOptions.WorkflowIDConflictPolicy = enumspb.WORKFLOW_ID_CONFLICT_POLICY_UNSPECIFIED
_, err = ts.client.NewWithStartWorkflowOperation(startOptions, ts.workflows.UpdateEntityWorkflow)
startOp = ts.client.NewWithStartWorkflowOperation(startOptions, ts.workflows.UpdateEntityWorkflow)
_, err = ts.client.UpdateWithStartWorkflow(ctx, updateOptions, startOp)
ts.ErrorContains(err, "WorkflowIDConflictPolicy must be set")
})

ts.Run("fails when update operation is invalid", func() {
startOptions := startWorkflowOptions()

startOp, err := ts.client.NewWithStartWorkflowOperation(startOptions, ts.workflows.UpdateEntityWorkflow)
ts.NoError(err)
startOp := ts.client.NewWithStartWorkflowOperation(startOptions, ts.workflows.UpdateEntityWorkflow)

_, err = ts.client.UpdateWithStartWorkflow(ctx,
_, err := ts.client.UpdateWithStartWorkflow(ctx,
client.UpdateWorkflowOptions{
// invalid
}, startOp)
Expand Down Expand Up @@ -4164,8 +4159,7 @@ func (ts *IntegrationTestSuite) TestUpdateWithStartWorkflow() {
startOptions := startWorkflowOptions()
_, err := ts.client.ExecuteWorkflow(ctx, startOptions, ts.workflows.UpdateEntityWorkflow)
ts.NoError(err)
startOp, err := ts.client.NewWithStartWorkflowOperation(startOptions, ts.workflows.UpdateEntityWorkflow)
ts.NoError(err)
startOp := ts.client.NewWithStartWorkflowOperation(startOptions, ts.workflows.UpdateEntityWorkflow)

_, err = ts.client.UpdateWithStartWorkflow(ctx,
client.UpdateWorkflowOptions{
Expand All @@ -4179,32 +4173,30 @@ func (ts *IntegrationTestSuite) TestUpdateWithStartWorkflow() {
})

ts.Run("fails when executed twice", func() {
startOp, err := ts.client.NewWithStartWorkflowOperation(startWorkflowOptions(), ts.workflows.UpdateEntityWorkflow)
ts.NoError(err)
startOp := ts.client.NewWithStartWorkflowOperation(startWorkflowOptions(), ts.workflows.UpdateEntityWorkflow)

updateOptions := client.UpdateWorkflowOptions{
UpdateName: "update",
Args: []any{1},
WaitForStage: client.WorkflowUpdateStageCompleted,
}
_, err = ts.client.UpdateWithStartWorkflow(ctx, updateOptions, startOp)
_, err := ts.client.UpdateWithStartWorkflow(ctx, updateOptions, startOp)
ts.NoError(err)

_, err = ts.client.UpdateWithStartWorkflow(ctx, updateOptions, startOp)
ts.ErrorContains(err, "invalid WithStartWorkflowOperation: was already executed")
})

ts.Run("propagates context", func() {
startOp, err := ts.client.NewWithStartWorkflowOperation(startWorkflowOptions(), ts.workflows.ContextPropagator, true)
ts.NoError(err)
startOp := ts.client.NewWithStartWorkflowOperation(startWorkflowOptions(), ts.workflows.ContextPropagator, true)

ctx := context.Background()
// Propagate values using different context propagators.
ctx = context.WithValue(ctx, contextKey(testContextKey1), "propagatedValue1")
ctx = context.WithValue(ctx, contextKey(testContextKey2), "propagatedValue2")
ctx = context.WithValue(ctx, contextKey(testContextKey3), "non-propagatedValue")

_, err = ts.client.UpdateWithStartWorkflow(ctx,
_, err := ts.client.UpdateWithStartWorkflow(ctx,
client.UpdateWorkflowOptions{
UpdateName: "update",
Args: []any{1},
Expand Down

0 comments on commit 2cf86f4

Please sign in to comment.