carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

1package host
2
3// Serial: it writes the package-level plans cache.
4
5import (
6 "testing"
7 "time"
8
9 "github.com/carlosframework/platform/internal/plans"
10 "github.com/carlosframework/platform/internal/registry"
11)
12
13func TestPlanIdleFor(t *testing.T) {
14 t.Cleanup(func() { planLimits.Store(nil) })
15 rt := registry.Route{Host: "a.example", Kind: "instance", Account: "bab", App: "web"}
16 planLimits.Store(nil)
17 if d := planIdleFor(rt); d != 0 {
18 t.Fatalf("plans off: %v, want 0", d)
19 }
20 planLimits.Store(&planLimitsSnapshot{byAccount: map[string]plans.Limits{"bab": {IdleSeconds: 90}}})
21 if d := planIdleFor(rt); d != 90*time.Second {
22 t.Fatalf("bab: %v, want 90s", d)
23 }
24 other := rt
25 other.Account = "bdk"
26 if d := planIdleFor(other); d != 0 {
27 t.Fatalf("account with no record: %v, want 0", d)
28 }
29}
30