mirror of
https://github.com/octoleo/restic.git
synced 2024-12-29 13:22:43 +00:00
27 lines
396 B
Go
27 lines
396 B
Go
package backoff
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"golang.org/x/net/context"
|
|
)
|
|
|
|
func TestContext(t *testing.T) {
|
|
b := NewConstantBackOff(time.Millisecond)
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
defer cancel()
|
|
|
|
cb := WithContext(b, ctx)
|
|
|
|
if cb.Context() != ctx {
|
|
t.Error("invalid context")
|
|
}
|
|
|
|
cancel()
|
|
|
|
if cb.NextBackOff() != Stop {
|
|
t.Error("invalid next back off")
|
|
}
|
|
}
|