package host // Serial: it writes the package-level plans cache. import ( "testing" "time" "github.com/carlosframework/platform/internal/plans" "github.com/carlosframework/platform/internal/registry" ) func TestPlanIdleFor(t *testing.T) { t.Cleanup(func() { planLimits.Store(nil) }) rt := registry.Route{Host: "a.example", Kind: "instance", Account: "bab", App: "web"} planLimits.Store(nil) if d := planIdleFor(rt); d != 0 { t.Fatalf("plans off: %v, want 0", d) } planLimits.Store(&planLimitsSnapshot{byAccount: map[string]plans.Limits{"bab": {IdleSeconds: 90}}}) if d := planIdleFor(rt); d != 90*time.Second { t.Fatalf("bab: %v, want 90s", d) } other := rt other.Account = "bdk" if d := planIdleFor(other); d != 0 { t.Fatalf("account with no record: %v, want 0", d) } }