Skip to content

Commit 0cc28f2

Browse files
test: add test for disable command with matching submodule name
This commit adds a test to ensure full test coverage for the scenario where `.gitmodules` contains an entry exactly matching the configuration name instead of falling back to searching by path. This verifies that when a submodule is added manually to `.gitmodules` using its configured name, `submod disable <name>` will find it and correctly update the `active = false` property in `.gitmodules`. Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com>
1 parent 1558b51 commit 0cc28f2

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

tests/integration_tests.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,39 @@ active = true
566566
assert!(gitmodules_content.contains("active = false"));
567567
}
568568

569+
#[test]
570+
fn test_disable_command_matching_name() {
571+
let harness = TestHarness::new().expect("Failed to create test harness");
572+
harness.init_git_repo().expect("Failed to init git repo");
573+
574+
// Manually create a .gitmodules with a matching name
575+
let gitmodules_content = "\
576+
[submodule \"my-lib\"]
577+
\tpath = lib/my
578+
\turl = https://example.com/my-lib.git
579+
";
580+
std::fs::write(harness.work_dir.join(".gitmodules"), gitmodules_content)
581+
.expect("Failed to write .gitmodules");
582+
583+
let config_content = "\
584+
[my-lib]
585+
path = \"lib/my\"
586+
url = \"https://example.com/my-lib.git\"
587+
active = true
588+
";
589+
harness.create_config(config_content).expect("Failed to create config");
590+
591+
let stdout = harness
592+
.run_submod_success(&["disable", "my-lib"])
593+
.expect("Failed to disable submodule");
594+
595+
assert!(stdout.contains("Disabled submodule 'my-lib'"));
596+
597+
let gitmodules_updated = std::fs::read_to_string(harness.work_dir.join(".gitmodules"))
598+
.expect("Failed to read .gitmodules");
599+
assert!(gitmodules_updated.contains("active = false"));
600+
}
601+
569602
#[test]
570603
fn test_disable_command_preserves_comments() {
571604
let harness = TestHarness::new().expect("Failed to create test harness");

0 commit comments

Comments
 (0)