Add Seriatim trim adapter support
This commit is contained in:
@@ -51,3 +51,51 @@ func TestFakeRunnerError(t *testing.T) {
|
||||
t.Fatal("expected error, got nil")
|
||||
}
|
||||
}
|
||||
|
||||
func TestFakeRunnerTrimCapturesRequestAndReturnsPath(t *testing.T) {
|
||||
fake := &FakeRunner{}
|
||||
dir := t.TempDir()
|
||||
req := TrimRequest{
|
||||
GeneratedConfigPath: filepath.Join(dir, "config", "seriatim.trim.yml"),
|
||||
InputTranscriptPath: filepath.Join(dir, "transcripts", "processed.json"),
|
||||
OutputTrimmedPath: filepath.Join(dir, "transcripts", "trimmed.json"),
|
||||
KeepSelector: "1-10",
|
||||
StdoutLogPath: filepath.Join(dir, "logs", "seriatim.trim.stdout.log"),
|
||||
StderrLogPath: filepath.Join(dir, "logs", "seriatim.trim.stderr.log"),
|
||||
}
|
||||
|
||||
res, err := fake.Trim(context.Background(), req)
|
||||
if err != nil {
|
||||
t.Fatalf("Trim() error = %v", err)
|
||||
}
|
||||
if len(fake.TrimRequests) != 1 || fake.TrimRequests[0].GeneratedConfigPath == "" {
|
||||
t.Fatalf("trim requests = %#v, want captured request", fake.TrimRequests)
|
||||
}
|
||||
if res.OutputTrimmedPath != req.OutputTrimmedPath {
|
||||
t.Fatalf("trimmed path = %q, want %q", res.OutputTrimmedPath, req.OutputTrimmedPath)
|
||||
}
|
||||
if res.KeepSelector != req.KeepSelector {
|
||||
t.Fatalf("keep selector = %q, want %q", res.KeepSelector, req.KeepSelector)
|
||||
}
|
||||
|
||||
cfgData, err := os.ReadFile(req.GeneratedConfigPath)
|
||||
if err != nil {
|
||||
t.Fatalf("read generated config: %v", err)
|
||||
}
|
||||
if !strings.Contains(string(cfgData), "command: trim") {
|
||||
t.Fatalf("generated config = %q, want trim command marker", string(cfgData))
|
||||
}
|
||||
for _, logPath := range []string{req.StdoutLogPath, req.StderrLogPath} {
|
||||
if _, err := os.Stat(logPath); err != nil {
|
||||
t.Fatalf("expected log file %q to exist: %v", logPath, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestFakeRunnerTrimError(t *testing.T) {
|
||||
fake := &FakeRunner{TrimErr: errors.New("boom")}
|
||||
_, err := fake.Trim(context.Background(), TrimRequest{})
|
||||
if err == nil {
|
||||
t.Fatal("expected error, got nil")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user