Skip to content

Commit 1558b51

Browse files
test: fix git2_ops_tests submodule name in write_gitmodules test
The `test_with_submodule_write_gitmodules_updates_existing` test was failing because the test added a submodule using the `submod add` command which, when using the git2 fallback, names the submodule entry in `.gitmodules` by its path ("lib/writesub") rather than the user-supplied name ("write-sub"). This commit updates the test to dynamically look up the correct submodule name and then sets `active = false` so that the `write_gitmodules` assertion correctly validates that the git configuration captures the active flag. Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com>
1 parent 2556667 commit 1558b51

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

tests/git_ops_tests.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,9 +395,16 @@ mod git2_ops_tests {
395395
ops.write_gitmodules(&entries).expect("write_gitmodules");
396396

397397
// Verify that updating `active` sets it in the git configuration
398-
if let Some(mut entry) = entries.get("write-sub").cloned() {
398+
// In .gitmodules the git2 fallback might name the submodule by its path 'lib/writesub'
399+
let name = if entries.get("write-sub").is_some() {
400+
"write-sub"
401+
} else {
402+
"lib/writesub"
403+
};
404+
405+
if let Some(mut entry) = entries.get(name).cloned() {
399406
entry.active = Some(false);
400-
entries.update_entry("write-sub".to_string(), entry);
407+
entries.update_entry(name.to_string(), entry);
401408
}
402409
ops.write_gitmodules(&entries).expect("write_gitmodules active false");
403410

0 commit comments

Comments
 (0)