Initial commit

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-15 13:57:10 +08:00
co-authored by Claude Opus 5
commit 8679200f41
1897 changed files with 257900 additions and 0 deletions
+47
View File
@@ -0,0 +1,47 @@
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)
}
})
}
}