Retain selected glossary instructions

This commit is contained in:
2026-11-26 18:14:27 +00:00
parent d2c4c63580
commit b1cde637a2
5 changed files with 51 additions and 2 deletions

View File

@@ -92,6 +92,29 @@ func TestResolveModuleRunSpecs(t *testing.T) {
}
}
func TestResolveGlossaryInstructions(t *testing.T) {
cfg := &config.Config{
GlossaryCollections: map[string]config.GlossaryCollection{
"one": {Instruction: "First"}, "two": {Instruction: "Second"}, "protected": {Instruction: "Protection only"},
},
Pipeline: config.Pipeline{Stages: []config.Stage{
{Module: "grammar", Glossaries: []string{"two", "one"}, ProtectedTerms: []string{"protected"}},
{Module: "grammar", Glossaries: []string{"two", "one"}, ProtectedTerms: []string{"protected"}},
{Module: "grammar", Glossaries: []string{"one"}, ProtectedTerms: []string{"protected"}},
}},
}
specs := ResolveModuleRunSpecs(cfg)
want := []GlossaryInstruction{{Collection: "two", Text: "Second"}, {Collection: "one", Text: "First"}}
for _, spec := range specs[:2] {
if !reflect.DeepEqual(spec.GlossaryInstructions, want) {
t.Fatalf("instructions = %+v, want %+v", spec.GlossaryInstructions, want)
}
}
if !reflect.DeepEqual(specs[2].GlossaryInstructions, want[1:]) {
t.Fatalf("specific selection = %+v", specs[2].GlossaryInstructions)
}
}
func TestSectionMetadataFromSection(t *testing.T) {
section := chunking.Section{
Index: 3,