Migrate pkg/parser/frontmatter_helpers_test.go to testify assertions#21108
Merged
Migrate pkg/parser/frontmatter_helpers_test.go to testify assertions#21108
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Migrates pkg/parser/frontmatter_helpers_test.go to use testify/assert and testify/require for more consistent, readable test assertions across pkg/parser.
Changes:
- Replaced
t.Fatal/t.Errorfand manualstrings.Containschecks withrequire/assert. - Added a new “verbose” test case wiring through the
verboseargument toUpdateWorkflowFrontmatter. - Simplified
EnsureToolsSectionverification by usingassert.Equalandrequireguards.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Comment on lines
+20
to
+26
| updateFunc func(frontmatter map[string]any) error | ||
| expectedContent string | ||
| expectError bool | ||
| verbose bool |
Comment on lines
+127
to
+138
| name: "Verbose mode does not affect output", | ||
| initialContent: `--- | ||
| engine: claude | ||
| --- | ||
| # Test`, | ||
| updateFunc: func(frontmatter map[string]any) error { | ||
| frontmatter["engine"] = "copilot" | ||
| return nil | ||
| }, | ||
| expectError: false, | ||
| verbose: true, | ||
| }, |
| } | ||
| } | ||
| // Verify returned tools matches the frontmatter entry and expected content | ||
| assert.Equal(t, frontmatterTools, tools, "returned tools should be the same reference as frontmatter['tools']") |
Contributor
|
@copilot apply comments |
…e test, prove reference identity by mutation Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Contributor
Author
Done in fa6f75a:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The only test file in
pkg/parser/not using testify — replaced 14 rawt.Fatal/t.Errorfcalls and manualstrings.Containschecks withrequire/assert, consistent with the rest of the package.Changes
"strings", addedtestify/assertandtestify/requireTestUpdateWorkflowFrontmatter:t.Fatalf/t.Errorf→require.NoError/assert.Errorstrings.Contains+t.Errorf→assert.Containsverbose boolfield and averbose=truetest case that verifies the frontmatter update is applied correctlyTestEnsureToolsSection: replaced 15-line manual nested-map comparison withassert.Equal; nil/type-assertion guards →require.NotNil/require.TrueTestReconstructWorkflowFile:t.Errorf+ early return →require.NoError+assert.EqualTestQuoteCronExpressions: not added — already exists inquote_cron_expressions_test.gowith 18 casesBefore / after (tools verification):