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

Function TestLoopUntil

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

Source from the content-addressed store, hash-verified

16}
17
18func TestLoopUntil(t *testing.T) {
19 step := Loop(counter(),
20 Until(func(ctx context.Context, s State, iter int) (bool, error) {
21 n, _ := strconv.Atoi(s.String())
22 return n >= 3, nil
23 }),
24 LoopMax(100),
25 )
26 out, err := step(context.Background(), State{Data: []byte("0")})
27 if err != nil {
28 t.Fatal(err)
29 }
30 if out.String() != "3" {
31 t.Fatalf("expected 3, got %q", out.String())
32 }
33}
34
35func TestLoopMaxCapStops(t *testing.T) {
36 runs := 0

Callers

nothing calls this directly

Calls 7

LoopFunction · 0.85
counterFunction · 0.85
UntilFunction · 0.85
LoopMaxFunction · 0.85
FatalMethod · 0.80
StringMethod · 0.65
FatalfMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…