fix: correct TOML deserialization test for SerializableBranch empty/whitespace rejection#37
Merged
bashandbone merged 2 commits intofeat/test-expansionfrom Mar 19, 2026
Merged
Conversation
…rly isolate SerializableBranch Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix serialization/deserialization bug and expand testing
fix: correct TOML deserialization test for SerializableBranch empty/whitespace rejection
Mar 19, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Updates a TOML deserialization test in src/options.rs to reflect how SerializableBranch is represented in real config files (as a field inside a TOML table), so the test reaches SerializableBranch’s validation logic instead of failing at the TOML top-level type.
Changes:
- Wrap
SerializableBranchin a local helper struct for TOML deserialization in the test. - Adjust the test inputs for empty and whitespace-only branch values (note: current raw strings are malformed and will still fail TOML parsing before validation).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
726
to
728
| // Empty string should be rejected | ||
| let res_empty: Result<SerializableBranch, toml::de::Error> = | ||
| toml::from_str("branch = \"\""); | ||
| let res_empty: Result<Helper, toml::de::Error> = toml::from_str(r#"branch = """#); | ||
| assert!(res_empty.is_err(), "expected error for empty branch value"); |
| // Whitespace-only string should be rejected | ||
| let res_ws: Result<SerializableBranch, toml::de::Error> = | ||
| toml::from_str("branch = \" \""); | ||
| let res_ws: Result<Helper, toml::de::Error> = toml::from_str(r#"branch = " ""#); |
bashandbone
added a commit
that referenced
this pull request
Mar 19, 2026
…in core areas. (#33) * feat: Add schema; delete old CLAUDE.md for regeneration. * fix: Fixed an issue with toml deserialization due to mismatched expectations between serialize and deserialize forms. Caught by some of the new expanded tests. * Apply suggestions from code review Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * fix: correct fetchRecurseSubmodules key lookup in from_gitmodules (#34) * Initial plan * fix: use correct fetchRecurseSubmodules key in from_gitmodules with fetchRecurse fallback Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com> * fix: SPDX headers in CLAUDE.md; delegate SerializableBranch deserialization to from_gitmodules (#36) * Initial plan * fix: add SPDX headers to CLAUDE.md; delegate SerializableBranch deserialization to from_gitmodules Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Relocate branch deserialization test to correct module Moved the test for branch deserialization from TOML to the appropriate test module. * fix: correct TOML deserialization test for SerializableBranch empty/whitespace rejection (#37) * Initial plan * fix: use wrapper struct for branch TOML deserialization test to properly isolate SerializableBranch Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com> --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
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.
test_branch_deserialize_from_toml_rejects_empty_and_whitespacewas failing because it attempted to deserialize directly intoSerializableBranchfrom a TOML key-value string — but TOML's top-level must be a table, so the deserializer received a map instead of a string and failed before reaching any branch validation logic.Fix
SerializableBranchin a helper struct for the test, matching how it actually appears in real config files:Previously,
toml::from_str::<SerializableBranch>("branch = \"\"")producedinvalid type: map, expected a stringinstead of the expectedinvalid branch valueerror.🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.