0a897419a5
Co-authored-by: multica-agent <github@multica.ai>
52 lines
1.1 KiB
Go
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)
|
|
}
|
|
})
|
|
}
|
|
}
|