Complete assembled validation and migrate remaining tests
This commit is contained in:
@@ -23,12 +23,7 @@ func (h testChunkProposalHarness) collectEnrichedProposals(
|
||||
transcript *schema.Transcript,
|
||||
sections []chunking.Section,
|
||||
) ([]proposals.EnrichedCorrectionProposal, error) {
|
||||
runSpecs, err := ResolveModuleRunSpecs([]string{h.module.Key()})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
runSpec := runSpecs[0]
|
||||
runSpec := ModuleRunSpec{ModuleKey: h.module.Key(), InstanceName: h.module.Key()}
|
||||
runSpec.ReplacementPolicy = h.module.ReplacementPolicy()
|
||||
|
||||
out := make([]proposals.EnrichedCorrectionProposal, 0)
|
||||
@@ -209,7 +204,7 @@ func TestApplyFakeProposalsAcrossMultipleChunksWithStaleSkip(t *testing.T) {
|
||||
t.Fatalf("collectEnrichedProposals failed: %v", err)
|
||||
}
|
||||
|
||||
result := proposals.ApplyProposals(transcript, enriched, module.ReplacementPolicy())
|
||||
result := proposals.ApplyProposals(transcript, enriched, module.ReplacementPolicy(), nil)
|
||||
|
||||
if len(result.Applied) != 2 {
|
||||
t.Fatalf("expected 2 applied changes, got %d", len(result.Applied))
|
||||
@@ -249,7 +244,7 @@ func TestChunkProposalCompositionDoesNotMutateNormalizedTranscript(t *testing.T)
|
||||
t.Fatalf("collectEnrichedProposals failed: %v", err)
|
||||
}
|
||||
|
||||
_ = proposals.ApplyProposals(transcript, enriched, module.ReplacementPolicy())
|
||||
_ = proposals.ApplyProposals(transcript, enriched, module.ReplacementPolicy(), nil)
|
||||
|
||||
if !reflect.DeepEqual(transcript, before) {
|
||||
t.Fatalf("normalized transcript mutated\nbefore=%+v\nafter=%+v", before, transcript)
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"gitea.maximumdirect.net/eric/audita/v3/internal/core/chunking"
|
||||
"gitea.maximumdirect.net/eric/audita/v3/internal/core/config"
|
||||
"gitea.maximumdirect.net/eric/audita/v3/internal/framework/proposals"
|
||||
"gitea.maximumdirect.net/eric/audita/v3/internal/framework/validators"
|
||||
)
|
||||
@@ -80,28 +81,14 @@ func TestInterfaceContractsCompileWithFakes(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestResolveModuleRunSpecs(t *testing.T) {
|
||||
specs, err := ResolveModuleRunSpecs([]string{"glossary", "homophones", "glossary", "spoken_word", "grammar"})
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
id := "named"
|
||||
cfg := &config.Config{Pipeline: config.Pipeline{Stages: []config.Stage{{Module: "glossary", ID: &id}, {Module: "grammar"}, {Module: "glossary"}}}}
|
||||
specs := ResolveModuleRunSpecs(cfg)
|
||||
if len(specs) != 3 || specs[0].Index != 0 || specs[0].ID == nil || *specs[0].ID != id || specs[0].InstanceName != "glossary_1" || specs[1].InstanceName != "grammar_2" || specs[2].InstanceName != "glossary_3" {
|
||||
t.Fatalf("unexpected specs: %+v", specs)
|
||||
}
|
||||
|
||||
expected := []ModuleRunSpec{
|
||||
{ModuleKey: "glossary", InstanceName: "glossary_1"},
|
||||
{ModuleKey: "homophones", InstanceName: "homophones"},
|
||||
{ModuleKey: "glossary", InstanceName: "glossary_2"},
|
||||
{ModuleKey: "spoken_word", InstanceName: "spoken_word"},
|
||||
{ModuleKey: "grammar", InstanceName: "grammar"},
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(specs, expected) {
|
||||
t.Fatalf("unexpected specs\nexpected: %+v\nactual: %+v", expected, specs)
|
||||
}
|
||||
}
|
||||
|
||||
func TestResolveModuleRunSpecsRejectsEmptyKey(t *testing.T) {
|
||||
_, err := ResolveModuleRunSpecs([]string{"glossary", ""})
|
||||
if err == nil {
|
||||
t.Fatal("expected error for empty module key")
|
||||
if len(ResolveModuleRunSpecs(nil)) != 0 {
|
||||
t.Fatal("nil configuration has run specs")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user