-
Notifications
You must be signed in to change notification settings - Fork 180
Expand file tree
/
Copy pathretry_policy_test.go
More file actions
36 lines (25 loc) · 930 Bytes
/
Copy pathretry_policy_test.go
File metadata and controls
36 lines (25 loc) · 930 Bytes
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
package river
import (
"testing"
"time"
"github.com/stretchr/testify/require"
"github.com/riverqueue/river/rivertype"
)
// Just proves that DefaultRetryPolicy implements the RetryPolicy interface.
var _ ClientRetryPolicy = &DefaultClientRetryPolicy{}
func TestDefaultClientRetryPolicy_NextRetry(t *testing.T) {
t.Parallel()
t.Run("ConfiguredTime", func(t *testing.T) {
t.Parallel()
now := time.Now().UTC()
retryPolicy := &DefaultClientRetryPolicy{timeNowFunc: func() time.Time { return now }}
nextRetryAt := retryPolicy.NextRetry(&rivertype.JobRow{})
require.WithinDuration(t, now.Add(time.Second), nextRetryAt, 150*time.Millisecond)
})
t.Run("ZeroValue", func(t *testing.T) {
t.Parallel()
retryPolicy := &DefaultClientRetryPolicy{}
nextRetryAt := retryPolicy.NextRetry(&rivertype.JobRow{})
require.WithinDuration(t, time.Now().UTC().Add(time.Second), nextRetryAt, 150*time.Millisecond)
})
}