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

40 lines
792 B
Go

package usermod
import (
"testing"
"time"
)
func TestGetPaymentStatusPopupNewUserIgnoresFreeWatchCount(t *testing.T) {
now := time.Now()
tests := []struct {
name string
watchCount uint64
want string
}{
{
name: "remaining free views stays new unpaid",
watchCount: 3,
want: UserPaymentStatusPopupNewUnpay,
},
{
name: "exhausted free views stays new unpaid",
watchCount: 0,
want: UserPaymentStatusPopupNewUnpay,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
user := &User{
CreatedAt: now.Add(-time.Hour),
WatchCount: tt.watchCount,
}
if got := user.GetPaymentStatusPopup(); got != tt.want {
t.Fatalf("GetPaymentStatusPopup() = %q, want %q", got, tt.want)
}
})
}
}