/usr/share/gocode/src/gopkg.in/eapache/go-resiliency.v1/retrier/backoffs_test.go is in golang-gopkg-eapache-go-resiliency.v1-dev 0.0~git20150213.0.6800482-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | package retrier
import (
"testing"
"time"
)
func TestConstantBackoff(t *testing.T) {
b := ConstantBackoff(1, 10*time.Millisecond)
if len(b) != 1 {
t.Error("incorrect length")
}
for i := range b {
if b[i] != 10*time.Millisecond {
t.Error("incorrect value at", i)
}
}
b = ConstantBackoff(10, 250*time.Hour)
if len(b) != 10 {
t.Error("incorrect length")
}
for i := range b {
if b[i] != 250*time.Hour {
t.Error("incorrect value at", i)
}
}
}
func TestExponentialBackoff(t *testing.T) {
b := ExponentialBackoff(1, 10*time.Millisecond)
if len(b) != 1 {
t.Error("incorrect length")
}
if b[0] != 10*time.Millisecond {
t.Error("incorrect value")
}
b = ExponentialBackoff(4, 1*time.Minute)
if len(b) != 4 {
t.Error("incorrect length")
}
if b[0] != 1*time.Minute {
t.Error("incorrect value")
}
if b[1] != 2*time.Minute {
t.Error("incorrect value")
}
if b[2] != 4*time.Minute {
t.Error("incorrect value")
}
if b[3] != 8*time.Minute {
t.Error("incorrect value")
}
}
|