40 lines
792 B
Go
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)
|
|
}
|
|
})
|
|
}
|
|
}
|