template-monorepo/internal/model/notification/usecase/backoff_test.go

23 lines
621 B
Go
Raw Permalink Normal View History

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}))
}