(t *testing.T)
| 49 | } |
| 50 | |
| 51 | func TestLoopOnIteration(t *testing.T) { |
| 52 | var seen []int |
| 53 | body := func(ctx context.Context, in State) (State, error) { return in, nil } |
| 54 | step := Loop(body, LoopMax(3), OnIteration(func(iter int, s State) { seen = append(seen, iter) })) |
| 55 | if _, err := step(context.Background(), State{}); err != nil { |
| 56 | t.Fatal(err) |
| 57 | } |
| 58 | if len(seen) != 3 || seen[0] != 1 || seen[2] != 3 { |
| 59 | t.Fatalf("expected iterations [1 2 3], got %v", seen) |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | func TestLoopBodyError(t *testing.T) { |
| 64 | body := func(ctx context.Context, in State) (State, error) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…