23 lines
621 B
Go
23 lines
621 B
Go
package usecase
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
notifconfig "gateway/internal/model/notification/config"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestRetryDelay_UsesBackoffSeconds(t *testing.T) {
|
|
cfg := notifconfig.AsyncConfig{BackoffSeconds: []int{1, 5, 30}}
|
|
assert.Equal(t, time.Second, retryDelay(cfg, 1))
|
|
assert.Equal(t, 5*time.Second, retryDelay(cfg, 2))
|
|
assert.Equal(t, 30*time.Second, retryDelay(cfg, 99))
|
|
}
|
|
|
|
func TestEffectiveMaxRetry_Default(t *testing.T) {
|
|
assert.Equal(t, 5, effectiveMaxRetry(notifconfig.AsyncConfig{}))
|
|
assert.Equal(t, 3, effectiveMaxRetry(notifconfig.AsyncConfig{MaxRetry: 3}))
|
|
}
|