Skip to content

Commit 773d45e

Browse files
runningcodeclaude
andcommitted
test(build): Combine redundant git metadata tests (EME-604)
Combine test_collect_git_metadata_respects_explicit_values_when_auto_collect_disabled and test_collect_git_metadata_with_explicit_vcs_provider into a single test that verifies both explicit head_sha and vcs_provider are respected when auto_collect is disabled, while also verifying that auto-inference doesn't happen for other fields. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 840a851 commit 773d45e

File tree

1 file changed

+11
-46
lines changed

1 file changed

+11
-46
lines changed

src/commands/build/upload.rs

Lines changed: 11 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ mod tests {
878878
// Bind a minimal config
879879
Config::from_cli_config().unwrap().bind_to_process();
880880

881-
// Create a mock ArgMatches with explicit --head-sha value
881+
// Create a mock ArgMatches with explicit --head-sha and --vcs-provider values
882882
let app = make_command(Command::new("test"));
883883
let matches = app
884884
.try_get_matches_from(vec![
@@ -889,6 +889,8 @@ mod tests {
889889
"test-project",
890890
"--head-sha",
891891
"1234567890123456789012345678901234567890",
892+
"--vcs-provider",
893+
"custom-vcs",
892894
"dummy.apk",
893895
])
894896
.unwrap();
@@ -898,16 +900,20 @@ mod tests {
898900
// When auto_collect is false, explicit values should still be collected
899901
let metadata = collect_git_metadata(&matches, &config, false);
900902

901-
// The explicit head_sha should be present
903+
// Explicit values should be present
902904
assert!(
903905
metadata.head_sha.is_some(),
904906
"Explicit --head-sha should be collected even with auto_collect=false"
905907
);
908+
assert_eq!(
909+
metadata.vcs_provider, "custom-vcs",
910+
"Explicit --vcs-provider should be used with auto_collect=false"
911+
);
906912

907-
// But automatic inference should not happen (these would be empty since auto_collect=false)
913+
// But automatic inference should not happen for fields without explicit values
908914
assert_eq!(
909-
metadata.vcs_provider, "",
910-
"vcs_provider should be empty with auto_collect=false and no explicit value"
915+
metadata.head_repo_name, "",
916+
"head_repo_name should be empty with auto_collect=false and no explicit value"
911917
);
912918
}
913919

@@ -960,45 +966,4 @@ mod tests {
960966
"head_ref should be empty with auto_collect=false and no explicit value"
961967
);
962968
}
963-
964-
#[test]
965-
fn test_collect_git_metadata_with_explicit_vcs_provider() {
966-
use std::env;
967-
use tempfile::TempDir;
968-
969-
// Create a temporary directory for config
970-
let temp_dir = TempDir::new().unwrap();
971-
env::set_current_dir(temp_dir.path()).unwrap();
972-
973-
// Create a minimal config file
974-
let config_path = temp_dir.path().join(".sentryclirc");
975-
std::fs::write(&config_path, "[defaults]\n").unwrap();
976-
977-
// Bind a minimal config
978-
Config::from_cli_config().unwrap().bind_to_process();
979-
980-
// Test that explicit --vcs-provider is respected with auto_collect=false
981-
let app = make_command(Command::new("test"));
982-
let matches = app
983-
.try_get_matches_from(vec![
984-
"test",
985-
"--org",
986-
"test-org",
987-
"--project",
988-
"test-project",
989-
"--vcs-provider",
990-
"custom-vcs",
991-
"dummy.apk",
992-
])
993-
.unwrap();
994-
995-
let config = Config::current();
996-
997-
let metadata = collect_git_metadata(&matches, &config, false);
998-
999-
assert_eq!(
1000-
metadata.vcs_provider, "custom-vcs",
1001-
"Explicit --vcs-provider should be used with auto_collect=false"
1002-
);
1003-
}
1004969
}

0 commit comments

Comments
 (0)