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
3import (
4 "context"
5 "testing"
6
7 "github.com/carlosframework/platform/internal/registry"
8 "github.com/carlosframework/platform/internal/release"
9)
10
11// These are the protected attribution/readiness fields consumed by the
12// production adoption pass. E3 settings and E4 consent join this matrix when
13// their owning track lands; this test claims no whole-registry conversion.
14func testPlan14RootProtectedDispatch(t *testing.T) {
15 cases := map[string]func(*registry.Route){
16 "canonical": func(*registry.Route) {},
17 "account": func(r *registry.Route) { r.Account = "bap" },
18 "app": func(r *registry.Route) { r.App = "other" },
19 "unit": func(r *registry.Route) { r.Unit = "other.service" },
20 "socket": func(r *registry.Route) { r.Socket = "/run/other.sock" },
21 "addr": func(r *registry.Route) { r.Addr = "127.0.0.1:1" },
22 "addrs": func(r *registry.Route) { r.Addrs = "127.0.0.1:1" },
23 "health": func(r *registry.Route) { r.Health = "null" },
24 "kind": func(r *registry.Route) { r.Kind = "static" },
25 "backing": func(r *registry.Route) { r.Backing = "exec" },
26 "channel": func(r *registry.Route) { r.Channel = "forged" },
27 "removed": nil,
28 }
29 for name, mutate := range cases {
30 t.Run(name, func(t *testing.T) {
31 e, rt, u, c, pub := plan14AdoptionFixture(t)
32 h := seedHostRootHistory(t, rt)
33 if mutate == nil {
34 if err := e.root.reg.Delete(rt.Host); err != nil {
35 t.Fatal(err)
36 }
37 } else {
38 mutate(&rt)
39 if err := e.root.reg.Upsert(rt); err != nil {
40 t.Fatal(err)
41 }
42 }
43 forward := rootRestartRouteWith(e.root.reg, u, u.opt, func(string) string { return "5s" }, e.root.obs.recordSettled(e.bake), c)
44 err := release.Pass(context.Background(), e.root.reg, e.store, pub, u.opt, forward, release.BakeDir(e.bake), release.WithRootHistory(boundRootHistory(h, c.resolve, e.root.obs)), release.WithRollbackRestart(rollbackUnitRestart(e.root.reg, u, u.opt, func(string) string { return "5s" }, c)))
45 if name == "canonical" {
46 if err != nil || len(u.effects) != 1 {
47 t.Fatal("canonical dispatch", err, u.effects)
48 }
49 } else if len(u.effects) != 0 {
50 t.Fatal("registry mutation dispatched", name, err, u.effects)
51 }
52 })
53 }
54 t.Run("observation-and-settle", TestPlan14ProofObservationRejectsForgedRegistry)
55 t.Run("held-publication", TestPlan14HeldRevalidatesCanonicalBindingUnderGuard)
56}
57