|
6 | 6 | "testing"
|
7 | 7 | "time"
|
8 | 8 |
|
| 9 | + "github.com/cschleiden/go-workflows/activity" |
9 | 10 | "github.com/cschleiden/go-workflows/client"
|
10 | 11 | "github.com/cschleiden/go-workflows/worker"
|
11 | 12 | "github.com/cschleiden/go-workflows/workflow"
|
@@ -75,6 +76,39 @@ var e2eActivityTests = []backendTest{
|
75 | 76 | require.NoError(t, err)
|
76 | 77 | },
|
77 | 78 | },
|
| 79 | + { |
| 80 | + name: "Activity_ReceiveAttempt", |
| 81 | + f: func(t *testing.T, ctx context.Context, c *client.Client, w *worker.Worker, b TestBackend) { |
| 82 | + var maxAttempt int |
| 83 | + |
| 84 | + a := func(ctx context.Context) error { |
| 85 | + attempt := activity.Attempt(ctx) |
| 86 | + maxAttempt = attempt |
| 87 | + |
| 88 | + if attempt < 2 { |
| 89 | + return &CustomError{msg: "custom error"} |
| 90 | + } |
| 91 | + |
| 92 | + return nil |
| 93 | + } |
| 94 | + |
| 95 | + wf := func(ctx workflow.Context) error { |
| 96 | + _, err := workflow.ExecuteActivity[int](ctx, workflow.ActivityOptions{ |
| 97 | + RetryOptions: workflow.RetryOptions{ |
| 98 | + MaxAttempts: 4, |
| 99 | + }, |
| 100 | + }, a).Get(ctx) |
| 101 | + |
| 102 | + return err |
| 103 | + } |
| 104 | + register(t, ctx, w, []interface{}{wf}, []interface{}{a}) |
| 105 | + |
| 106 | + _, err := runWorkflowWithResult[bool](t, ctx, c, wf) |
| 107 | + require.NoError(t, err) |
| 108 | + |
| 109 | + require.Equal(t, 2, maxAttempt) |
| 110 | + }, |
| 111 | + }, |
78 | 112 | {
|
79 | 113 | name: "Activity_ExtendTask",
|
80 | 114 | customWorkerOptions: func(w *worker.Options) {
|
|
0 commit comments