Files
rootandClaude Opus 5 8679200f41 Initial commit
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-15 13:57:10 +08:00

48 lines
1022 B
Go

package usermod
import (
"testing"
"time"
)
func TestRenewVIPLevel(t *testing.T) {
now := time.Date(2026, 8, 29, 12, 0, 0, 0, time.UTC)
tests := []struct {
name string
currentExpire time.Time
currentLevel int
renewedLevel int
want int
}{
{
name: "preserves active higher level",
currentExpire: now.Add(24 * time.Hour),
currentLevel: 3,
renewedLevel: 1,
want: 3,
},
{
name: "upgrades active lower level",
currentExpire: now.Add(24 * time.Hour),
currentLevel: 1,
renewedLevel: 3,
want: 3,
},
{
name: "uses renewed level after expiration",
currentExpire: now.Add(-time.Second),
currentLevel: 3,
renewedLevel: 1,
want: 1,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := RenewVIPLevel(tt.currentExpire, now, tt.currentLevel, tt.renewedLevel); got != tt.want {
t.Fatalf("RenewVIPLevel() = %d, want %d", got, tt.want)
}
})
}
}