Harden render validation tests for input paths and empty transcript output
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user