MCPcopy Create free account
hub / github.com/The-Pocket/PocketFlow-Go / TestNodeRetryFailureWithoutFallback

Function TestNodeRetryFailureWithoutFallback

pocketflow_test.go:247–263  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

245}
246
247func 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
265func TestBatchNodeItemRetryAndFallback(t *testing.T) {
266 itemExecCounts := make(map[string]int)

Callers

nothing calls this directly

Calls 4

SetExecMethod · 0.80
ErrorMethod · 0.80
RunMethod · 0.65
SetRetryMethod · 0.45

Tested by

no test coverage detected