TestCompileErrorFormatting verifies that compilation errors use console.FormatErrorMessage
(t *testing.T)
| 20 | |
| 21 | // TestCompileErrorFormatting verifies that compilation errors use console.FormatErrorMessage |
| 22 | func TestCompileErrorFormatting(t *testing.T) { |
| 23 | // Create a temporary test workflow with invalid frontmatter |
| 24 | tempDir := t.TempDir() |
| 25 | invalidWorkflow := tempDir + "/invalid.md" |
| 26 | |
| 27 | // Write invalid workflow (missing closing frontmatter delimiter) |
| 28 | err := os.WriteFile(invalidWorkflow, []byte(`--- |
| 29 | name: test |
| 30 | engine: invalid_engine |
| 31 | This is not valid frontmatter |
| 32 | `), 0644) |
| 33 | require.NoError(t, err, "Failed to write test file") |
| 34 | |
| 35 | // Capture stderr |
| 36 | oldStderr := os.Stderr |
| 37 | r, w, _ := os.Pipe() |
| 38 | os.Stderr = w |
| 39 | |
| 40 | // Create compiler and attempt to compile |
| 41 | compiler := workflow.NewCompiler() |
| 42 | _ = CompileWorkflowWithValidation(context.Background(), compiler, invalidWorkflow, CompileValidationOptions{}) |
| 43 | |
| 44 | // Restore stderr and read captured output |
| 45 | w.Close() |
| 46 | os.Stderr = oldStderr |
| 47 | |
| 48 | var buf bytes.Buffer |
| 49 | _, _ = io.Copy(&buf, r) |
| 50 | _ = buf.String() // Capture but don't use (just verifying no panic) |
| 51 | |
| 52 | // Since we can't easily test for the exact formatting (would require TTY detection), |
| 53 | // we verify that the test runs without panic |
| 54 | // The actual formatting is tested in other tests below |
| 55 | } |
| 56 | |
| 57 | // TestResolveWorkflowErrorFormatting verifies that workflow resolution errors use console formatting |
| 58 | func TestResolveWorkflowErrorFormatting(t *testing.T) { |
nothing calls this directly
no test coverage detected