-
Notifications
You must be signed in to change notification settings - Fork 1
Add task parsing test with selectors and custom fields #176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds test coverage for task frontmatter parsing, specifically focusing on handling selectors with array values and custom fields that aren't part of the typed TaskFrontMatter struct. The changes enhance the test suite to validate that both typed fields and arbitrary YAML fields in the Content map are correctly unmarshaled.
Key Changes:
- Added a new test case "task with selectors and custom fields" demonstrating parsing of
single_shot,collect_and_push, andselectorswith array values - Enhanced test validation logic to check custom
Contentfields beyond typed struct fields - Added validation for the
Selectorsmap to ensure selector values are properly unmarshaled
| gotVal, exists := got.Selectors[key] | ||
| if !exists { | ||
| t.Errorf("Selectors[%q] missing, want %v", key, wantVal) | ||
| } else if fmt.Sprintf("%v", gotVal) != fmt.Sprintf("%v", wantVal) { |
Copilot
AI
Dec 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same fragile comparison logic using fmt.Sprintf("%v") is used here. For comparing map values (especially nested structures like arrays), this string-based comparison is unreliable and may lead to false positives or false negatives.
Consider using reflect.DeepEqual or a proper testing comparison library for accurate validation of complex selector values.
| yaml: `--- | ||
| single_shot: true | ||
| collect_and_push: false | ||
| selectors: | ||
| tool: [""] | ||
| --- | ||
| Say hello. | ||
| `, |
Copilot
AI
Dec 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test input includes YAML document delimiters (---) which are inconsistent with other test cases in this file. All other test cases provide raw YAML without delimiters. Since this test directly calls yaml.Unmarshal, it should follow the same pattern as other tests and exclude the delimiters.
While go-yaml may accept document delimiters, maintaining consistency with the existing test pattern improves readability and clearly shows that this is testing YAML unmarshaling, not markdown frontmatter extraction.
| yaml: `--- | |
| single_shot: true | |
| collect_and_push: false | |
| selectors: | |
| tool: [""] | |
| --- | |
| Say hello. | |
| `, | |
| yaml: `single_shot: true | |
| collect_and_push: false | |
| selectors: | |
| tool: | |
| - ""`, |
| gotVal, exists := got.Content[key] | ||
| if !exists { | ||
| t.Errorf("Content[%q] missing, want %v", key, wantVal) | ||
| } else if fmt.Sprintf("%v", gotVal) != fmt.Sprintf("%v", wantVal) { |
Copilot
AI
Dec 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comparison logic using fmt.Sprintf("%v") is fragile and can produce false positives. For comparing slices and maps, this approach converts them to string representation which may not accurately reflect equality. For example, []any{""} and []string{""} will have different string representations even though they contain the same values.
Consider using a proper deep equality check such as reflect.DeepEqual or a testing library like github.com/google/go-cmp/cmp for more reliable comparisons of complex types.
Adds test coverage for task frontmatter parsing with selectors containing array values and custom fields that aren't part of the typed struct.
Changes
New test case in
TestTaskFrontMatter_Unmarshalcovering:single_shot: true(typed field)collect_and_push: false(custom field stored inContentmap)selectors: tool: [""](selector with array value)Enhanced validation to check custom
Contentfields andSelectorsmap beyond the existing typed field checksExample test input:
This ensures the YAML unmarshaler correctly populates both typed
TaskFrontMatterfields and the underlyingContentmap for arbitrary frontmatter fields.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.