MCPcopy Create free account
hub / github.com/github/gh-aw / TestCompileErrorFormatting

Function TestCompileErrorFormatting

pkg/cli/error_formatting_test.go:22–55  ·  view source on GitHub ↗

TestCompileErrorFormatting verifies that compilation errors use console.FormatErrorMessage

(t *testing.T)

Source from the content-addressed store, hash-verified

20
21// TestCompileErrorFormatting verifies that compilation errors use console.FormatErrorMessage
22func 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(`---
29name: test
30engine: invalid_engine
31This 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
58func TestResolveWorkflowErrorFormatting(t *testing.T) {

Callers

nothing calls this directly

Calls 5

NewCompilerFunction · 0.92
BackgroundMethod · 0.80
CloseMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected