Files
mesh-host/internal/declaration/emitted_check_test.go
T
jschoubben d81f826089 A check that what the control plane emits is what this host accepts
"The host needs no new vocabulary" is the load-bearing claim behind every
computed and contributed resource on the other side, and it had never
been tested against this parser — only asserted.

Skipped unless MESH_EMITTED names a file, so it stays a check somebody
runs deliberately rather than a dependency between two repositories.

  mesh-control plan <node> --json > /tmp/d.json
  MESH_EMITTED=/tmp/d.json go test ./internal/declaration/ -v

Confirmed to fail when the declaration carries an action, which is the
thing this parser exists to refuse.
2026-08-29 23:35:11 +02:00

34 lines
1.0 KiB
Go

package declaration
import (
"os"
"testing"
)
// The control plane's actual output, put through the host's actual parser.
//
// Skipped unless MESH_EMITTED names a file, so this is a check somebody runs deliberately rather
// than a dependency between two repositories. It exists because "the host needs no new
// vocabulary" is the load-bearing claim of every computed and contributed resource, and the only
// honest way to know it is to hand the host one and see.
func TestWhatTheControlPlaneEmittedIsSomethingThisHostAccepts(t *testing.T) {
path := os.Getenv("MESH_EMITTED")
if path == "" {
t.Skip("set MESH_EMITTED to a declaration the control plane produced")
}
raw, err := os.ReadFile(path)
if err != nil {
t.Fatal(err)
}
d, err := Parse(raw)
if err != nil {
t.Fatalf("the host refuses what the control plane sends:\n%v", err)
}
if len(d.Resources) == 0 {
t.Fatal("parsed, and empty")
}
for _, r := range d.Resources {
t.Logf("accepted %s %s → %s", r.Kind(), r.Identity(), r.Target())
}
}