seatgen: no seat list and no root package, definitions in any folder, seat-list-grain files generate nothing, packages with a dependency-free lock (ADR 0635 §1, ADR 0634 §8, F7; issue 1966)
Claude-Session: https://claude.ai/code/session_01JG73KJNrH5EgFXMKKYSrig
This commit is contained in:
@@ -85,7 +85,6 @@ func TestAPackageWithNeitherScriptNorTypeScriptHasNoTests(t *testing.T) {
|
||||
m, _, work = newMachine(t)
|
||||
workspaceWith(t, work, map[string]string{
|
||||
"module.json": `{"module":"c","build":{"artifacts":[{"name":"ts","kind":"package","language":"typescript","paths":["ts"],"generated-from":"."}]}}`,
|
||||
"seats/index.json": `{"format":1,"seats":["one-store"]}`,
|
||||
"seats/one-store/seat.json": `{"format":1,"seat":"one-store","scope":"mesh","grain":"seat-list","decision":"ADR 1","verbs":[{"name":"query","input":{"type":"object"}}]}`,
|
||||
"go/go.mod": "module example.org/c/go\n", "go/stray.go": "package stray\n",
|
||||
"ts/package.json": `{"name":"@example/c"}`, "ts/stray.ts.txt": "not written by the generator\n",
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"testing"
|
||||
|
||||
"git.novox.be/novox/mesh-catalog/modules/mesh-build-go/buildstep/seatgen"
|
||||
)
|
||||
|
||||
// F7 (ADR 0625 §5, ADR 0634 §8): a package the seat generator wrote, with its dependency-free lock and no script, is
|
||||
// installed from that lock (npm ci) and packed (npm pack) with no build script run, as any package artifact is.
|
||||
func TestAGeneratedSeatPackageIsInstalledFromItsLockAndPackedWithoutABuild(t *testing.T) {
|
||||
m, f, work := newMachine(t)
|
||||
seat := `{"format":1,"seat":"one-store","scope":"mesh","grain":"whole","decision":"ADR 1","verbs":[{"name":"query","input":{"type":"object"},"answer":{"type":"object"}}]}`
|
||||
src := t.TempDir()
|
||||
write(t, filepath.Join(src, "seats", "one-store", "seat.json"), seat, 0o644)
|
||||
g, err := seatgen.Load(src, "example.org/c/go", "@example/c")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
files, err := seatgen.Generate(g)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
dir := filepath.Join(work, "w1", "tree", "ts", "seats", "onestore")
|
||||
for _, name := range []string{"package.json", "package-lock.json"} {
|
||||
body, ok := files["ts/seats/onestore/"+name]
|
||||
if !ok {
|
||||
t.Fatalf("the generator wrote no %s for the seat's package", name)
|
||||
}
|
||||
write(t, filepath.Join(dir, name), string(body), 0o644)
|
||||
}
|
||||
f.effect = func(c call) {
|
||||
if c.name == "npm" && len(c.args) > 0 && c.args[0] == "pack" {
|
||||
dest := c.args[slices.Index(c.args, "--pack-destination")+1]
|
||||
write(t, filepath.Join(dest, "example-c-one-store-0.1.0.tgz"), "tgz", 0o644)
|
||||
}
|
||||
}
|
||||
ctx := context.Background()
|
||||
if err := m.installDev(ctx, work, dir, "ts/seats/onestore"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
p, err := m.buildAndPack(ctx, work, dir, "ts/seats/onestore", false, "")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if p.Name != "@example/c-one-store" || p.Version != "0.1.0" {
|
||||
t.Errorf("packed %s@%s", p.Name, p.Version)
|
||||
}
|
||||
var ran []string
|
||||
for _, c := range f.calls {
|
||||
if c.name == "npm" {
|
||||
ran = append(ran, c.args[0])
|
||||
}
|
||||
}
|
||||
if !slices.Equal(ran, []string{"ci", "pack"}) {
|
||||
t.Errorf("npm ran %v, want ci then pack and no build script", ran)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user