-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbackoff_test.go
35 lines (25 loc) · 1.07 KB
/
backoff_test.go
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
package client
import (
"testing"
"github.com/cenkalti/backoff/v4"
"github.com/stretchr/testify/assert"
)
// TestWithRandomizationFactor_ConfigureExponentialBackoff checks if the WithRandomizationFactor
// function correctly sets the randomization factor of an ExponentialBackoff instance
// when used with the ConfigureExponentialBackoff method.
func TestWithRandomizationFactor_ConfigureExponentialBackoff(t *testing.T) {
t.Parallel()
bo := backoff.NewExponentialBackOff()
rf := WithRandomizationFactor(0.5)
rf.ConfigureExponentialBackoff(bo)
assert.Equal(t, 0.5, bo.RandomizationFactor, "RandomizationFactor not set properly")
}
// TestWithMultiplierConfigureExponentialBackoff ensures that the ConfigureExponentialBackoff
// function correctly configures the ExponentialBackoff object with the desired multipler value.
func TestWithMultiplierConfigureExponentialBackoff(t *testing.T) {
t.Parallel()
bo := backoff.NewExponentialBackOff()
w := WithMultiplier(2.0)
w.ConfigureExponentialBackoff(bo)
assert.Equal(t, 2.0, bo.Multiplier, "Multiplier not set properly")
}