gitee.com/gricks/utils@v1.0.8/backoff/backoff_test.go (about) 1 package backoff 2 3 import ( 4 "testing" 5 6 . "github.com/smartystreets/goconvey/convey" 7 ) 8 9 func Test_Backoff(t *testing.T) { 10 Convey("Backoff", t, func() { 11 b := DefaultStrategy 12 So(b.Backoff(0), ShouldEqual, b.BaseDelay) 13 So(b.Backoff(0), ShouldEqual, b.BaseDelay) 14 So(b.Backoff(1000), ShouldBeLessThanOrEqualTo, b.MaxDelay*2) 15 for i := 0; i < 100; i++ { 16 t.Log(i, b.Backoff(i)) 17 } 18 }) 19 }