@@ -0,0 +1,39 @@
|
||||
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)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user