Harden render validation tests for input paths and empty transcript output

This commit is contained in:
2026-05-24 23:00:10 +00:00
parent 761d70bbc6
commit 6dfc1ea527
2 changed files with 74 additions and 0 deletions

View File

@@ -895,6 +895,46 @@ func TestNewRenderConfigAppliesDefaultsAndFlags(t *testing.T) {
}
}
func TestNewRenderConfigRejectsMissingAndDirectoryInputFile(t *testing.T) {
dir := t.TempDir()
output := filepath.Join(dir, "rendered.md")
missingInput := filepath.Join(dir, "missing.json")
_, err := NewRenderConfig(validRenderOptions(missingInput, output))
if err == nil {
t.Fatal("expected missing input-file error")
}
if !strings.Contains(err.Error(), "--input-file") {
t.Fatalf("unexpected error: %v", err)
}
inputDir := filepath.Join(dir, "input-dir")
if err := os.MkdirAll(inputDir, 0o700); err != nil {
t.Fatalf("mkdir input dir: %v", err)
}
_, err = NewRenderConfig(validRenderOptions(inputDir, output))
if err == nil {
t.Fatal("expected directory input-file error")
}
if !strings.Contains(err.Error(), "is a directory, not a file") {
t.Fatalf("unexpected error: %v", err)
}
}
func TestNewRenderConfigRejectsMissingOutputParent(t *testing.T) {
dir := t.TempDir()
input := writeTempFile(t, dir, "input.json")
output := filepath.Join(dir, "missing-parent", "rendered.md")
_, err := NewRenderConfig(validRenderOptions(input, output))
if err == nil {
t.Fatal("expected output parent directory error")
}
if !strings.Contains(err.Error(), "--output-file parent directory") {
t.Fatalf("unexpected error: %v", err)
}
}
func assertPositiveFloatEnvValidation(t *testing.T, envName string) {
t.Helper()