32 lines
884 B
Go
32 lines
884 B
Go
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")
|
|
}
|
|
}
|