fix(core): keep workspace runtime available

This commit is contained in:
Codex
2026-09-08 13:37:10 +02:00
parent 50c546e42d
commit 818563c408
6 changed files with 192 additions and 24 deletions
@@ -56,6 +56,50 @@ func TestRenderProducesDeterministicCatalogPiAndComposeProjections(t *testing.T)
}
}
func TestGenerateDoesNotReplaceUnchangedProjection(t *testing.T) {
installation := projectionFixture(t)
if err := Generate(installation); err != nil {
t.Fatalf("Generate() initial error = %v", err)
}
paths := []string{
installation.GeneratedModelCatalogPath(),
installation.GeneratedPiModelsPath(),
installation.GeneratedPiSettingsPath(),
installation.ModelProjectionComposePath(),
}
before := make(map[string]os.FileInfo, len(paths))
for _, path := range paths {
info, err := os.Stat(path)
if err != nil {
t.Fatal(err)
}
before[path] = info
}
originalRename := renameProjectionDirectory
t.Cleanup(func() { renameProjectionDirectory = originalRename })
renames := 0
renameProjectionDirectory = func(oldPath, newPath string) error {
renames++
return os.Rename(oldPath, newPath)
}
if err := Generate(installation); err != nil {
t.Fatalf("Generate() repeated error = %v", err)
}
if renames != 0 {
t.Fatalf("Generate() replaced an unchanged generation with %d renames", renames)
}
for _, path := range paths {
after, err := os.Stat(path)
if err != nil {
t.Fatal(err)
}
if !os.SameFile(before[path], after) {
t.Fatalf("Generate() replaced unchanged artifact %q", path)
}
}
}
func TestGenerateRestoresWholePreviousGenerationWhenPublishFails(t *testing.T) {
installation := projectionFixture(t)
if err := Generate(installation); err != nil {