Verify the integrated resilient processing contract
This commit is contained in:
@@ -83,6 +83,26 @@ func TestPrepareOutputPreservesExistingTranscriptAndChecksParent(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAtomicReplacementCleansTemporaryFileAfterRenameFailure(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
blocked := filepath.Join(dir, "directory-target")
|
||||
if err := os.Mkdir(blocked, 0700); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := atomicReplace(blocked, []byte("new content")); err == nil {
|
||||
t.Fatal("directory replacement unexpectedly succeeded")
|
||||
}
|
||||
entries, err := os.ReadDir(dir)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, entry := range entries {
|
||||
if strings.HasPrefix(entry.Name(), ".audita-write-") {
|
||||
t.Fatalf("replacement left temporary file: %s", entry.Name())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestDisabledReportingIgnoresUnusableDirectory(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
session, err := PrepareOutput(OutputSelection{TranscriptPath: filepath.Join(dir, "out.json"), ReportDir: filepath.Join(dir, "missing"), ReportingEnabled: false})
|
||||
|
||||
@@ -279,7 +279,10 @@ func TestRunnerKeepsSectionMembershipAfterTextGrowth(t *testing.T) {
|
||||
cfg.Chunking.MaxSectionTokens = 3
|
||||
cfg.Chunking.MinSectionTokens = 0
|
||||
transcript := &schema.Transcript{Segments: []schema.Segment{
|
||||
{ID: 1, Text: "a"}, {ID: 2, Text: "b"}, {ID: 3, Text: "c"}, {ID: 4, Text: "d"},
|
||||
{ID: 1, Speaker: "A", Start: 0, End: 1, Text: "a"},
|
||||
{ID: 2, Speaker: "B", Start: 1, End: 2, Text: "b"},
|
||||
{ID: 3, Speaker: "A", Start: 2, End: 3, Text: "c"},
|
||||
{ID: 4, Speaker: "B", Start: 3, End: 4, Text: "d"},
|
||||
}}
|
||||
var mu sync.Mutex
|
||||
seen := make(map[int][]int)
|
||||
@@ -302,6 +305,9 @@ func TestRunnerKeepsSectionMembershipAfterTextGrowth(t *testing.T) {
|
||||
if req.Section.Index == 0 && req.WorkingTranscript.Segments[0].Text != updatedText {
|
||||
return nil, errors.New("later module did not see updated section text")
|
||||
}
|
||||
if req.Section.Index == 0 {
|
||||
return []proposals.CorrectionProposal{{TargetSegmentID: 3, OriginalText: "c", CorrectedText: "C", Confidence: 1}}, nil
|
||||
}
|
||||
return nil, nil
|
||||
}},
|
||||
}})
|
||||
@@ -315,9 +321,15 @@ func TestRunnerKeepsSectionMembershipAfterTextGrowth(t *testing.T) {
|
||||
if len(seen) != 2 || len(seen[0]) != 2 || seen[0][0] != 1 || seen[0][1] != 2 || len(seen[1]) != 2 || seen[1][0] != 3 || seen[1][1] != 4 {
|
||||
t.Fatalf("later module saw changed section membership: %+v", seen)
|
||||
}
|
||||
if len(out.FinalTranscript.Segments) != 4 || out.FinalTranscript.Segments[0].Text != updatedText || out.FinalTranscript.Segments[3].ID != 4 {
|
||||
if len(out.FinalTranscript.Segments) != 4 || out.FinalTranscript.Segments[0].Text != updatedText || out.FinalTranscript.Segments[2].Text != "c" || out.FinalTranscript.Segments[3].ID != 4 {
|
||||
t.Fatalf("recombined transcript: %+v", out.FinalTranscript)
|
||||
}
|
||||
for i, segment := range out.FinalTranscript.Segments {
|
||||
original := transcript.Segments[i]
|
||||
if segment.ID != original.ID || segment.Speaker != original.Speaker || segment.Start != original.Start || segment.End != original.End {
|
||||
t.Fatalf("segment %d metadata changed: %+v", i, segment)
|
||||
}
|
||||
}
|
||||
if out.WorkUnits[0].CorrectionsApplied != 1 || out.WorkUnits[1].CorrectionsApplied != 0 {
|
||||
t.Fatalf("section application counts: %+v", out.WorkUnits)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user