| 245 | } |
| 246 | |
| 247 | func TestNodeRetryFailureWithoutFallback(t *testing.T) { |
| 248 | execCount := 0 |
| 249 | node := pf.NewNode(). |
| 250 | SetRetry(2, 1*time.Millisecond). // Use time.Millisecond |
| 251 | SetExec(func(ctx *pf.PfContext, params map[string]any, prepResult any) (any, error) { |
| 252 | execCount++ |
| 253 | return nil, fmt.Errorf("permanent failure %d", execCount) // Always fail |
| 254 | }) |
| 255 | // No fallback set |
| 256 | ctx := pf.WithParam(context.Background(), nil) |
| 257 | |
| 258 | _, err := node.Run(ctx) |
| 259 | require.Error(t, err) |
| 260 | assert.ErrorContains(t, err, "Exec phase failed") |
| 261 | assert.ErrorContains(t, err, "permanent failure 2") // Check cause |
| 262 | assert.Equal(t, 2, execCount, "Exec should have been called 2 times") |
| 263 | } |
| 264 | |
| 265 | func TestBatchNodeItemRetryAndFallback(t *testing.T) { |
| 266 | itemExecCounts := make(map[string]int) |