Define adapter interfaces and fake implementations

This commit is contained in:
2026-05-02 11:16:27 -05:00
parent 78e7e4f41b
commit 2854da48c2
24 changed files with 876 additions and 73 deletions

View File

@@ -0,0 +1,31 @@
package audita
import (
"context"
"errors"
"testing"
)
func TestFakeRunnerCapturesRequestAndReturnsPath(t *testing.T) {
fake := &FakeRunner{}
req := PolishRequest{GeneratedConfigPath: "config/audita.yml", OutputProcessedPath: "transcripts/processed.json"}
res, err := fake.Run(context.Background(), req)
if err != nil {
t.Fatalf("Run() error = %v", err)
}
if len(fake.Requests) != 1 || fake.Requests[0].GeneratedConfigPath == "" {
t.Fatalf("requests = %#v, want captured request", fake.Requests)
}
if res.ProcessedTranscriptPath != req.OutputProcessedPath {
t.Fatalf("processed path = %q, want %q", res.ProcessedTranscriptPath, req.OutputProcessedPath)
}
}
func TestFakeRunnerError(t *testing.T) {
fake := &FakeRunner{Err: errors.New("boom")}
_, err := fake.Run(context.Background(), PolishRequest{})
if err == nil {
t.Fatal("expected error, got nil")
}
}