返回 DeepSeek-Reasonix
retry_test.go
根目录 / internal / installlayout / retry_test.go
1 package installlayout
2
3 import (
4 "errors"
5 "testing"
6 "time"
7 )
8
9 func TestRetryTransientStopsOnPermanentErrors(t *testing.T) {
10 restore := transientRetryDelay
11 transientRetryDelay = func(time.Duration) { t.Fatal("permanent errors must not back off") }
12 t.Cleanup(func() { transientRetryDelay = restore })
13
14 permanent := errors.New("permanent")
15 attempts := 0
16 err := retryTransient(func() error { attempts++; return permanent })
17 if !errors.Is(err, permanent) || attempts != 1 {
18 t.Fatalf("attempts=%d err=%v", attempts, err)
19 }
20 attempts = 0
21 if err := retryTransient(func() error { attempts++; return nil }); err != nil || attempts != 1 {
22 t.Fatalf("attempts=%d err=%v", attempts, err)
23 }
24 }
25
25 lines GO