Files
hi-server/internal/logic/common/promoEligibility_test.go
T
2026-05-27 01:44:11 -07:00

52 lines
1.1 KiB
Go

package common
import (
"testing"
"time"
)
func TestIsInactivePromoEligible(t *testing.T) {
now := time.Date(2026, time.May, 27, 12, 0, 0, 0, time.UTC)
tests := []struct {
name string
expireAt time.Time
want bool
}{
{
name: "expired before inactive threshold is eligible",
expireAt: now.AddDate(0, -4, 0),
want: true,
},
{
name: "expired exactly at inactive threshold is eligible",
expireAt: now.AddDate(0, -3, 0),
want: true,
},
{
name: "recently expired subscription is not eligible",
expireAt: now.AddDate(0, -2, 0),
want: false,
},
{
name: "active future subscription is not eligible",
expireAt: now.Add(time.Hour),
want: false,
},
{
name: "permanent subscription marker is not eligible",
expireAt: time.UnixMilli(0),
want: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := isInactivePromoEligible(tt.expireAt, now, 3)
if got != tt.want {
t.Fatalf("isInactivePromoEligible() = %v, want %v", got, tt.want)
}
})
}
}