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,40 @@
package audita
import "context"
// NoopRunner is a deterministic no-op audita adapter.
type NoopRunner struct{}
// Run returns requested output path with placeholder metadata.
func (n *NoopRunner) Run(ctx context.Context, req PolishRequest) (PolishResult, error) {
if err := ctx.Err(); err != nil {
return PolishResult{}, err
}
return PolishResult{ProcessedTranscriptPath: req.OutputProcessedPath, Metadata: map[string]any{"placeholder": true}}, nil
}
// FakeRunner captures polish requests and returns deterministic responses.
type FakeRunner struct {
Requests []PolishRequest
Err error
Result PolishResult
}
// Run records request and returns configured response.
func (f *FakeRunner) Run(ctx context.Context, req PolishRequest) (PolishResult, error) {
if err := ctx.Err(); err != nil {
return PolishResult{}, err
}
f.Requests = append(f.Requests, req)
if f.Err != nil {
return PolishResult{}, f.Err
}
res := f.Result
if res.ProcessedTranscriptPath == "" {
res.ProcessedTranscriptPath = req.OutputProcessedPath
}
if res.Metadata == nil {
res.Metadata = map[string]any{"fake": true}
}
return res, nil
}

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")
}
}

View File

@@ -3,18 +3,22 @@ package audita
import "context"
// Runner is a placeholder adapter interface for audita invocation.
// Runner is the adapter boundary for audita polish invocations.
type Runner interface {
Run(ctx context.Context, req PolishRequest) (PolishResult, error)
}
// PolishRequest is a placeholder polish input.
// PolishRequest describes an audita invocation.
type PolishRequest struct {
GeneratedConfigPath string
MergedTranscriptPath string
OutputPath string
OutputProcessedPath string
StdoutLogPath string
StderrLogPath string
}
// PolishResult is a placeholder polish output.
// PolishResult describes a polish output.
type PolishResult struct {
ProcessedPath string
ProcessedTranscriptPath string
Metadata map[string]any
}