Extend the DUOLINGO far-future expires_at pattern to IELTS, backfill existing IELTS rows, and limit expiry sweeps to LEARN_ENGLISH only. Co-authored-by: Cursor <cursoragent@cursor.com>
44 lines
1.3 KiB
Go
44 lines
1.3 KiB
Go
package learnernotifications
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"Yimaru-Backend/internal/domain"
|
|
)
|
|
|
|
func TestSubscriptionPackageLabel(t *testing.T) {
|
|
if got := subscriptionPackageLabel("IELTS"); got != "IELTS" {
|
|
t.Fatalf("got %q", got)
|
|
}
|
|
if got := subscriptionPackageLabel("learn_english"); got != "Learn English" {
|
|
t.Fatalf("got %q", got)
|
|
}
|
|
}
|
|
|
|
func TestSubscriptionExpiresLabel(t *testing.T) {
|
|
expiresAt := time.Date(2026, 12, 31, 0, 0, 0, 0, time.UTC)
|
|
|
|
label, lifetime := subscriptionExpiresLabel(string(domain.SubscriptionCategoryIELTS), expiresAt)
|
|
if !lifetime || label != "" {
|
|
t.Fatalf("IELTS label=%q lifetime=%v", label, lifetime)
|
|
}
|
|
|
|
label, lifetime = subscriptionExpiresLabel(string(domain.SubscriptionCategoryDuolingo), expiresAt)
|
|
if !lifetime || label != "" {
|
|
t.Fatalf("DUOLINGO label=%q lifetime=%v", label, lifetime)
|
|
}
|
|
|
|
label, lifetime = subscriptionExpiresLabel(string(domain.SubscriptionCategoryLearnEnglish), expiresAt)
|
|
if lifetime || label != "Dec 31, 2026" {
|
|
t.Fatalf("LEARN_ENGLISH label=%q lifetime=%v", label, lifetime)
|
|
}
|
|
}
|
|
|
|
func TestSubscriptionActivatedMessage(t *testing.T) {
|
|
msg := subscriptionActivatedMessage(string(domain.SubscriptionCategoryIELTS), "Premium")
|
|
if msg == "" || msg == "Premium" {
|
|
t.Fatalf("unexpected message: %q", msg)
|
|
}
|
|
}
|