| Index: common/lazyslot/lazyslot_test.go
|
| diff --git a/common/lazyslot/lazyslot_test.go b/common/lazyslot/lazyslot_test.go
|
| index c8b50a2d5596a6cd93d6c13d15701b05766ad85b..f0f9a1b63dd22a0193d8ca83a9604d6c38c0bf89 100644
|
| --- a/common/lazyslot/lazyslot_test.go
|
| +++ b/common/lazyslot/lazyslot_test.go
|
| @@ -5,13 +5,16 @@
|
| package lazyslot
|
|
|
| import (
|
| + "fmt"
|
| "sync"
|
| "testing"
|
| "time"
|
|
|
| "golang.org/x/net/context"
|
|
|
| + "github.com/luci/luci-go/common/clock"
|
| "github.com/luci/luci-go/common/clock/testclock"
|
| + "github.com/luci/luci-go/common/retry"
|
|
|
| . "github.com/luci/luci-go/common/testing/assertions"
|
| . "github.com/smartystreets/goconvey/convey"
|
| @@ -140,6 +143,32 @@ func TestLazySlot(t *testing.T) {
|
| _, err := s.Get(c)
|
| So(err, ShouldErrLike, "lazyslot.Slot Fetcher returned nil value")
|
| })
|
| +
|
| + Convey("Does retries", t, func(conv C) {
|
| + c, clk := newContext()
|
| +
|
| + clk.SetTimerCallback(func(d time.Duration, t clock.Timer) {
|
| + if testclock.HasTags(t, "retry") {
|
| + clk.Add(d)
|
| + }
|
| + })
|
| +
|
| + lock := sync.Mutex{}
|
| + calls := 0
|
| +
|
| + s := Slot{
|
| + RetryFactory: retry.Default,
|
| + Fetcher: func(c context.Context, prev Value) (Value, error) {
|
| + lock.Lock()
|
| + calls++
|
| + lock.Unlock()
|
| + return Value{}, fmt.Errorf("omg, error")
|
| + },
|
| + }
|
| + _, err := s.Get(c)
|
| + So(err, ShouldErrLike, "context deadline exceeded")
|
| + So(calls, ShouldEqual, 8) // depends on retry config and deadline
|
| + })
|
| }
|
|
|
| func newContext() (context.Context, testclock.TestClock) {
|
|
|