Allow disjoint glossary overrides alongside shared files

This commit is contained in:
2026-11-29 18:43:13 +00:00
parent e72f69c68b
commit fb612b361d
6 changed files with 127 additions and 9 deletions

View File

@@ -247,3 +247,51 @@ func TestSharedGlossaryReadinessBeforeRequests(t *testing.T) {
t.Fatalf("local preflight: status=%d calls=%d stderr=%s", status, calls.Load(), stderr.String())
}
}
func TestSharedGlossaryWithDisjointNativeOverrides(t *testing.T) {
dir := t.TempDir()
main := filepath.Join(dir, "config.yml")
if err := os.WriteFile(main, []byte("version: 3\nglossary_collections:\n people:\n entries: [{id: configured, name: Configured, category: person}]\n"), 0600); err != nil {
t.Fatal(err)
}
for _, tc := range []struct{ name, collections, wantName string }{
{"populated", "{people: {entries: [{id: a, name: Alice, category: person}]}}", "Alice"},
{"empty", "{}", "Configured"},
} {
t.Run(tc.name, func(t *testing.T) {
file := filepath.Join(dir, tc.name+".yml")
if err := os.WriteFile(file, []byte("schema_version: maximumdirect.glossary.v1\ncollections: "+tc.collections+"\n"), 0600); err != nil {
t.Fatal(err)
}
common := []string{"--scope=app", "--config", main, "--glossary-file", file, "--set", `/glossary_collections/other/entries=[{"id":"b","name":"Bob","category":"person"}]`}
var out, stderr bytes.Buffer
if code := Run(context.Background(), append([]string{"config", "show"}, common...), &out, &stderr); code != 0 || !strings.Contains(out.String(), "name: "+tc.wantName) || !strings.Contains(out.String(), "name: Bob") {
t.Fatalf("show: code=%d out=%s stderr=%s", code, out.String(), stderr.String())
}
for _, origin := range []struct{ path, flag string }{
{"/glossary_collections/other/entries", "--set"},
{"/glossary_collections/people/entries", "--glossary-file"},
} {
if tc.name == "empty" && origin.flag == "--glossary-file" {
continue
}
out.Reset()
stderr.Reset()
args := append([]string{"config", "explain"}, common...)
args = append(args, "--path", origin.path)
if code := Run(context.Background(), args, &out, &stderr); code != 0 || !strings.Contains(out.String(), origin.flag) {
t.Fatalf("explain: code=%d out=%s stderr=%s", code, out.String(), stderr.String())
}
}
if tc.name == "populated" {
out.Reset()
stderr.Reset()
args := append([]string{"config", "show"}, common...)
args = append(args, "--set", `/glossary_collections/people={"entries":[]}`)
if code := Run(context.Background(), args, &out, &stderr); code != 2 || !strings.Contains(stderr.String(), "override.overlap") {
t.Fatalf("overlap: code=%d stderr=%s", code, stderr.String())
}
}
})
}
}