Skip to content

Commit 2cf67a8

Browse files
runningcodeclaude
andcommitted
test(build): Use fixed version override for deterministic test fixtures
Solves the maintenance problem where the test fixture SHA would change with every CLI version release. Now uses SENTRY_CLI_VERSION_OVERRIDE environment variable to set a fixed version (0.0.0-test) in tests, ensuring stable SHA checksums across releases. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent b7db7a8 commit 2cf67a8

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

src/utils/build/normalize.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@ use walkdir::WalkDir;
1616
use zip::write::SimpleFileOptions;
1717
use zip::{DateTime, ZipWriter};
1818

19+
fn get_version() -> String {
20+
#[cfg(test)]
21+
{
22+
std::env::var("SENTRY_CLI_VERSION_OVERRIDE").unwrap_or_else(|_| VERSION.to_string())
23+
}
24+
#[cfg(not(test))]
25+
{
26+
VERSION.to_string()
27+
}
28+
}
29+
1930
fn sort_entries(path: &Path) -> Result<impl Iterator<Item = (PathBuf, PathBuf)>> {
2031
Ok(WalkDir::new(path)
2132
.into_iter()
@@ -86,8 +97,9 @@ fn metadata_file_options() -> SimpleFileOptions {
8697
pub fn write_version_metadata<W: std::io::Write + std::io::Seek>(
8798
zip: &mut ZipWriter<W>,
8899
) -> Result<()> {
100+
let version = get_version();
89101
zip.start_file(".sentry-cli-metadata.txt", metadata_file_options())?;
90-
writeln!(zip, "sentry-cli-version: {VERSION}")?;
102+
writeln!(zip, "sentry-cli-version: {version}")?;
91103
Ok(())
92104
}
93105

68 Bytes
Binary file not shown.

tests/integration/build/upload.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ static CONTENT_TYPE_REGEX: LazyLock<Regex> = LazyLock::new(|| {
109109
/// and that the data sent to the chunk upload endpoint is exactly as expected.
110110
/// It also verifies that the correct calls are made to the assemble endpoint.
111111
fn command_build_upload_apk_chunked() {
112+
// Override version for deterministic binary comparison of chunk content
113+
std::env::set_var("SENTRY_CLI_VERSION_OVERRIDE", "0.0.0-test");
114+
112115
let is_first_assemble_call = AtomicBool::new(true);
113116
let expected_chunk_body = fs::read("tests/integration/_expected_requests/build/apk_chunk.bin")
114117
.expect("expected chunk body file should be present");
@@ -162,7 +165,7 @@ fn command_build_upload_apk_chunked() {
162165
if is_first_assemble_call.swap(false, Ordering::Relaxed) {
163166
r#"{
164167
"state": "created",
165-
"missingChunks": ["985f82b2ff9f3749f9d4c71ecb02e0396b9bc5a3"]
168+
"missingChunks": ["4c57ae0573fd4342c8996f9b2c9efd00ac84b5ea"]
166169
}"#
167170
} else {
168171
r#"{

0 commit comments

Comments
 (0)