Skip to content

test(parser): migrate frontmatter_extraction_test.go to testify + add missing coverage#36149

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/testify-expert-improve-test-quality-another-one
Draft

test(parser): migrate frontmatter_extraction_test.go to testify + add missing coverage#36149
Copilot wants to merge 2 commits into
mainfrom
copilot/testify-expert-improve-test-quality-another-one

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 31, 2026

pkg/parser/frontmatter_extraction_test.go used raw t.Errorf/t.Fatalf throughout and left ExtractWorkflowNameFromContent and ExtractWorkflowNameFromMarkdownBody entirely untested.

Testify migration

  • Replaced all t.Errorf/t.Fatalf with require.NoError/require.Error/assert.Equal
  • Dropped manual map iteration in TestExtractFrontmatterFromContent — replaced with a single assert.Equal on the whole map
  • Removed reflect.DeepEqual + reflect import in favour of assert.Equal
// Before
if len(tt.wantYAML) != len(result.Frontmatter) {
    t.Errorf("frontmatter length = %v, want %v", ...)
}
for key, expectedValue := range tt.wantYAML {
    if actualValue, exists := result.Frontmatter[key]; !exists {
        t.Errorf("missing key %v", key)
    } else if actualValue != expectedValue {
        t.Errorf("frontmatter[%v] = %v, want %v", ...)
    }
}

// After
assert.Equal(t, tt.wantYAML, result.Frontmatter, "frontmatter should match expected")

New test coverage

  • TestExtractWorkflowNameFromMarkdownBody — 6 cases: H1 found, trimmed whitespace, no H1 (filename fallback), empty body, H1 after prose, full-path fallback
  • TestExtractWorkflowNameFromContent — 6 cases: H1 with frontmatter, H1 without frontmatter, no H1 fallback, empty content, unclosed frontmatter error, full-path fallback

…dd missing tests

- Replace all t.Errorf/t.Fatalf with assert.*/require.* assertions
- Replace manual map iteration with assert.Equal in TestExtractFrontmatterFromContent
- Replace reflect.DeepEqual with assert.Equal (remove reflect import)
- Add TestExtractWorkflowNameFromMarkdownBody with 6 test cases
- Add TestExtractWorkflowNameFromContent with 6 test cases
- Add descriptive messages to all assertions

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Copilot AI changed the title [WIP] Improve test quality in frontmatter extraction test test(parser): migrate frontmatter_extraction_test.go to testify + add missing coverage May 31, 2026
Copilot AI requested a review from gh-aw-bot May 31, 2026 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[testify-expert] Improve Test Quality: pkg/parser/frontmatter_extraction_test.go

2 participants