package smtp

import (
	"testing"
	"time"
)

func TestOutboxRetryDelay_exponentialCap(t *testing.T) {
	d0 := OutboxRetryDelay(0)
	if d0 != baseRetryDelay {
		t.Fatalf("retry 0 = %v, want %v", d0, baseRetryDelay)
	}
	d3 := OutboxRetryDelay(3)
	if d3 != 4*time.Minute {
		t.Fatalf("retry 3 = %v, want 4m", d3)
	}
	dLarge := OutboxRetryDelay(20)
	if dLarge != maxRetryDelay {
		t.Fatalf("retry 20 = %v, want cap %v", dLarge, maxRetryDelay)
	}
	if OutboxRetryDelay(1) <= OutboxRetryDelay(0) {
		t.Fatal("expected increasing backoff")
	}
	if OutboxRetryDelay(10) > time.Hour {
		t.Fatal("delay must not exceed one hour")
	}
}
