v0.297.0: burn-down round 2 — 24 small rows (R-591 R-568 R-567 R-363 R-547 R-10 R-552 R-251 R-104 R-619 R-362 R-675 R-256 R-257 R-240 R-365 R-425 R-565 R-564 R-603 R-454 R-208 R-457-swept) + the banner countdown and deepCopyStack twins; MinAgent 0.131.0
gates / gates (push) Failing after 50s
gates / gates (push) Failing after 50s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
package stacks
|
||||
|
||||
import "testing"
|
||||
|
||||
// R-591: deepCopyStack is "a snapshot the caller may mutate". Before the fix the Meta.I18n map
|
||||
// (and every pointer inside each overlay) was shared, so writing through the copy changed the
|
||||
// original. The test asserts the CONSEQUENCE: after mutating the copy at every depth, the
|
||||
// original still reads its own values.
|
||||
func TestDeepCopyStackI18nIsNotShared(t *testing.T) {
|
||||
s := func(v string) *string { return &v }
|
||||
orig := &Stack{Name: "demo"}
|
||||
orig.Meta.I18n = map[string]MetadataOverlay{
|
||||
"en": {
|
||||
Description: s("orig desc"),
|
||||
AppInfo: &AppInfoOverlay{Tagline: s("orig tag"), UseCases: []string{"orig use"}},
|
||||
DeployFields: []DeployFieldOverlay{{EnvVar: "A", Label: s("orig label"),
|
||||
Options: []SelectOptionOverlay{{Value: "x", Label: s("orig opt")}}}},
|
||||
OptionalConfig: []OptionalConfigGroupOverlay{{MatchGroup: "g", Group: s("orig group"),
|
||||
Fields: []OptionalConfigFieldOverlay{{EnvVar: "B", HelpText: s("orig help")}}}},
|
||||
Integrations: []IntegrationOverlay{{Target: "t", Label: s("orig int")}},
|
||||
DataPaths: []DataPathOverlay{{Path: "/p", Label: s("orig path")}},
|
||||
InitialCreds: &InitialCredentialsOverlay{Note: s("orig note")},
|
||||
},
|
||||
}
|
||||
|
||||
cp := deepCopyStack(orig)
|
||||
en := cp.Meta.I18n["en"]
|
||||
*en.Description = "MUT"
|
||||
*en.AppInfo.Tagline = "MUT"
|
||||
en.AppInfo.UseCases[0] = "MUT"
|
||||
*en.DeployFields[0].Label = "MUT"
|
||||
*en.DeployFields[0].Options[0].Label = "MUT"
|
||||
*en.OptionalConfig[0].Group = "MUT"
|
||||
*en.OptionalConfig[0].Fields[0].HelpText = "MUT"
|
||||
*en.Integrations[0].Label = "MUT"
|
||||
*en.DataPaths[0].Label = "MUT"
|
||||
*en.InitialCreds.Note = "MUT"
|
||||
cp.Meta.I18n["de"] = MetadataOverlay{Description: s("MUT")}
|
||||
|
||||
o := orig.Meta.I18n["en"]
|
||||
checks := map[string]string{
|
||||
"description": *o.Description,
|
||||
"tagline": *o.AppInfo.Tagline,
|
||||
"use case": o.AppInfo.UseCases[0],
|
||||
"deploy label": *o.DeployFields[0].Label,
|
||||
"option label": *o.DeployFields[0].Options[0].Label,
|
||||
"optional group": *o.OptionalConfig[0].Group,
|
||||
"optional help": *o.OptionalConfig[0].Fields[0].HelpText,
|
||||
"integration": *o.Integrations[0].Label,
|
||||
"data path": *o.DataPaths[0].Label,
|
||||
"initial creds": *o.InitialCreds.Note,
|
||||
}
|
||||
for what, got := range checks {
|
||||
if got == "MUT" {
|
||||
t.Errorf("R-591: mutating the copy's %s overlay changed the ORIGINAL — the overlay is shared, not copied", what)
|
||||
}
|
||||
}
|
||||
if _, ok := orig.Meta.I18n["de"]; ok {
|
||||
t.Errorf("R-591: adding a language to the copy's I18n map added it to the ORIGINAL — the map is shared")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user