MCPcopy Create free account
hub / github.com/cloud-native-go/examples / EmulateTransientError

Function EmulateTransientError

ch04/retry_test.go:29–37  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

27var count int
28
29func EmulateTransientError(ctx context.Context) (string, error) {
30 count++
31
32 if count <= 3 {
33 return "intentional fail", errors.New("error")
34 } else {
35 return "success", nil
36 }
37}
38
39func TestRetry(t *testing.T) {
40 ctx := context.Background()

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected