32 lines
895 B
Go
32 lines
895 B
Go
package seriatim
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"testing"
|
|
)
|
|
|
|
func TestFakeRunnerCapturesRequestAndReturnsPath(t *testing.T) {
|
|
fake := &FakeRunner{}
|
|
req := MergeRequest{GeneratedConfigPath: "config/seriatim.yml", OutputMergedTranscriptPath: "transcripts/merged.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.MergedTranscriptPath != req.OutputMergedTranscriptPath {
|
|
t.Fatalf("merged path = %q, want %q", res.MergedTranscriptPath, req.OutputMergedTranscriptPath)
|
|
}
|
|
}
|
|
|
|
func TestFakeRunnerError(t *testing.T) {
|
|
fake := &FakeRunner{Err: errors.New("boom")}
|
|
_, err := fake.Run(context.Background(), MergeRequest{})
|
|
if err == nil {
|
|
t.Fatal("expected error, got nil")
|
|
}
|
|
}
|