@@ -9,6 +9,12 @@ import (
99 "github.com/stretchr/testify/require"
1010)
1111
12+ type exp struct {
13+ eq time.Duration
14+ gte time.Duration
15+ lte time.Duration
16+ }
17+
1218func TestDelays (t * testing.T ) {
1319 duration := func (s string ) (d time.Duration ) {
1420 d , err := time .ParseDuration (s )
@@ -42,11 +48,6 @@ func TestDelays(t *testing.T) {
4248}
4349
4450func TestLogBackoff (t * testing.T ) {
45- type exp struct {
46- eq time.Duration
47- gte time.Duration
48- lte time.Duration
49- }
5051 for _ , tt := range []struct {
5152 backoff Backoff
5253 exp []exp
@@ -145,24 +146,28 @@ func TestLogBackoff(t *testing.T) {
145146
146147 continue
147148 }
148- if gte := exp .gte ; act <= gte {
149- t .Errorf (
150- "unexpected Backoff delay: %s; want >= %s" ,
151- act , gte ,
152- )
153- }
154- if lte := exp .lte ; act >= lte {
155- t .Errorf (
156- "unexpected Backoff delay: %s; want <= %s" ,
157- act , lte ,
158- )
159- }
149+ checkExpWithAct (t , exp , act )
160150 }
161151 }
162152 })
163153 }
164154}
165155
156+ func checkExpWithAct (t * testing.T , exp exp , act time.Duration ) {
157+ if gte := exp .gte ; act <= gte {
158+ t .Errorf (
159+ "unexpected Backoff delay: %s; want >= %s" ,
160+ act , gte ,
161+ )
162+ }
163+ if lte := exp .lte ; act >= lte {
164+ t .Errorf (
165+ "unexpected Backoff delay: %s; want <= %s" ,
166+ act , lte ,
167+ )
168+ }
169+ }
170+
166171func TestFastSlowDelaysWithoutJitter (t * testing.T ) {
167172 for _ , tt := range []struct {
168173 name string
0 commit comments