mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-06 13:26:38 +08:00
Fix logo assets and license heartbeat
This commit is contained in:
@@ -2,6 +2,7 @@ package handler
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/ShukeBta/MediaStationGo/internal/service"
|
||||
)
|
||||
@@ -90,3 +91,30 @@ func TestLicenseHeartbeatPayloadIncludesStoredLicenseKey(t *testing.T) {
|
||||
t.Fatalf("heartbeat should include stored license key for server-side backfill: %#v", payload)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLicenseHeartbeatDueUsesTwelveHourWindow(t *testing.T) {
|
||||
state := service.LicenseActivationState{
|
||||
Valid: true,
|
||||
UpdatedAt: time.Now().Add(-11 * time.Hour).Format(time.RFC3339),
|
||||
}
|
||||
if licenseHeartbeatDue(state, 12*time.Hour) {
|
||||
t.Fatalf("heartbeat should not be due before interval")
|
||||
}
|
||||
|
||||
state.UpdatedAt = time.Now().Add(-13 * time.Hour).Format(time.RFC3339)
|
||||
if !licenseHeartbeatDue(state, 12*time.Hour) {
|
||||
t.Fatalf("heartbeat should be due after interval")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLicenseHeartbeatEligibleRequiresActivationState(t *testing.T) {
|
||||
if licenseHeartbeatEligible(service.LicenseActivationState{DeviceID: "device-only"}) {
|
||||
t.Fatalf("device id alone should not trigger automatic license heartbeat")
|
||||
}
|
||||
if !licenseHeartbeatEligible(service.LicenseActivationState{LicenseKey: "MS-KEY"}) {
|
||||
t.Fatalf("stored license key should trigger automatic license heartbeat")
|
||||
}
|
||||
if !licenseHeartbeatEligible(service.LicenseActivationState{Valid: true}) {
|
||||
t.Fatalf("valid license state should trigger automatic license heartbeat")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user