MCPcopy Index your code
hub / github.com/micro/go-micro / TestLoopOnIteration

Function TestLoopOnIteration

flow/loop_test.go:51–61  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

49}
50
51func 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
63func TestLoopBodyError(t *testing.T) {
64 body := func(ctx context.Context, in State) (State, error) {

Callers

nothing calls this directly

Calls 5

LoopFunction · 0.85
LoopMaxFunction · 0.85
OnIterationFunction · 0.85
FatalMethod · 0.80
FatalfMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…