Files
huangguo_server/models/v/usermod/drama_expire_test.go
T
rootandClaude Opus 5 8679200f41 Initial commit
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-15 13:57:10 +08:00

28 lines
756 B
Go

package usermod
import (
"testing"
"time"
)
func TestRenewDramaExpire(t *testing.T) {
now := time.Date(2026, 8, 26, 12, 0, 0, 0, time.UTC)
tests := []struct {
name string
current time.Time
days int
want time.Time
}{
{name: "starts from now", days: 30, want: now.AddDate(0, 0, 30)},
{name: "extends active entitlement", current: now.AddDate(0, 0, 10), days: 30, want: now.AddDate(0, 0, 40)},
{name: "refunds active entitlement", current: now.AddDate(0, 0, 30), days: -7, want: now.AddDate(0, 0, 23)},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := RenewDramaExpire(tt.current, now, tt.days); !got.Equal(tt.want) {
t.Fatalf("RenewDramaExpire() = %s, want %s", got, tt.want)
}
})
}
}