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

Function TestSpec_PublicAPI_ExtractMarkdownSection

pkg/parser/spec_test.go:57–84  ·  view source on GitHub ↗

TestSpec_PublicAPI_ExtractMarkdownSection validates the documented behavior of ExtractMarkdownSection as described in the package README.md. Specification: Extracts a named ## section from markdown.

(t *testing.T)

Source from the content-addressed store, hash-verified

55//
56// Specification: Extracts a named ## section from markdown.
57func TestSpec_PublicAPI_ExtractMarkdownSection(t *testing.T) {
58 t.Run("extracts the named section content", func(t *testing.T) {
59 content := "# Title\n\n## Tools\n\nSome tool config.\n\n## Other\n\nOther stuff."
60 section, err := ExtractMarkdownSection(content, "Tools")
61 require.NoError(t, err,
62 "ExtractMarkdownSection should not error when section exists")
63 assert.Contains(t, section, "Some tool config",
64 "extracted section should contain the body following the matched heading")
65 })
66
67 t.Run("returns error when section is not found", func(t *testing.T) {
68 content := "# Title\n\n## Tools\n\nSome tool config."
69 _, err := ExtractMarkdownSection(content, "Missing")
70 assert.Error(t, err,
71 "ExtractMarkdownSection should return error when the requested section is absent")
72 })
73
74 t.Run("stops at next same-or-higher level heading", func(t *testing.T) {
75 content := "## Tools\n\nTool A.\n\n## Engine\n\nEngine X."
76 section, err := ExtractMarkdownSection(content, "Tools")
77 require.NoError(t, err,
78 "ExtractMarkdownSection should not error when section exists")
79 assert.Contains(t, section, "Tool A",
80 "extracted section should contain text from inside the matched section")
81 assert.NotContains(t, section, "Engine X",
82 "extracted section should not bleed into the next ## section")
83 })
84}
85
86// TestSpec_PublicAPI_IsWorkflowSpec validates the documented behavior of
87// IsWorkflowSpec as described in the package README.md.

Callers

nothing calls this directly

Calls 3

ExtractMarkdownSectionFunction · 0.85
RunMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected