Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- (snapshots) Add `snapshots diff` command for locally comparing directories of PNG snapshot images using odiff ([#3306](https://github.com/getsentry/sentry-cli/pull/3306))
- (snapshots) Add `snapshots download` command for downloading baseline snapshot images from Sentry ([#3310](https://github.com/getsentry/sentry-cli/pull/3310))
- (snapshots) Add `--all-image-file-names` and `--all-image-file-names-file` flags to `snapshots upload` for detecting image removals and renames in selective builds ([#3312](https://github.com/getsentry/sentry-cli/pull/3312))
- (snapshots) Add `--all-image-file-names-as-regex` and `--all-image-file-names-as-regex-file` flags to `snapshots upload` for regex-based image name matching in selective builds ([#3316](https://github.com/getsentry/sentry-cli/pull/3316))

### Fixes

Expand Down
42 changes: 42 additions & 0 deletions src/api/data_types/snapshots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ pub struct SnapshotsManifest<'a> {
pub selective: bool,
#[serde(skip_serializing_if = "Option::is_none")]
pub all_image_file_names: Option<Vec<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub all_image_file_names_as_regex: Option<Vec<String>>,
#[serde(flatten)]
pub vcs_info: VcsInfo<'a>,
}
Expand Down Expand Up @@ -86,6 +88,7 @@ mod tests {
diff_threshold: None,
selective: false,
all_image_file_names: None,
all_image_file_names_as_regex: None,
vcs_info: empty_vcs_info(),
};
let json = serde_json::to_value(&manifest).unwrap();
Expand All @@ -100,6 +103,7 @@ mod tests {
diff_threshold: None,
selective: true,
all_image_file_names: None,
all_image_file_names_as_regex: None,
vcs_info: empty_vcs_info(),
};
let json = serde_json::to_value(&manifest).unwrap();
Expand All @@ -114,6 +118,7 @@ mod tests {
diff_threshold: None,
selective: true,
all_image_file_names: None,
all_image_file_names_as_regex: None,
vcs_info: empty_vcs_info(),
};
let json = serde_json::to_value(&manifest).unwrap();
Expand All @@ -131,12 +136,49 @@ mod tests {
diff_threshold: None,
selective: true,
all_image_file_names: Some(vec!["a.png".into(), "b.png".into()]),
all_image_file_names_as_regex: None,
vcs_info: empty_vcs_info(),
};
let json = serde_json::to_value(&manifest).unwrap();
assert_eq!(json["all_image_file_names"], json!(["a.png", "b.png"]));
}

#[test]
fn manifest_omits_all_image_file_names_as_regex_when_none() {
let manifest = SnapshotsManifest {
app_id: "app".into(),
images: HashMap::new(),
diff_threshold: None,
selective: true,
all_image_file_names: None,
all_image_file_names_as_regex: None,
vcs_info: empty_vcs_info(),
};
let json = serde_json::to_value(&manifest).unwrap();
assert!(!json
.as_object()
.unwrap()
.contains_key("all_image_file_names_as_regex"));
}

#[test]
fn manifest_includes_all_image_file_names_as_regex_when_some() {
let manifest = SnapshotsManifest {
app_id: "app".into(),
images: HashMap::new(),
diff_threshold: None,
selective: true,
all_image_file_names: None,
all_image_file_names_as_regex: Some(vec![".*\\.png".into(), "screens/.*".into()]),
vcs_info: empty_vcs_info(),
};
let json = serde_json::to_value(&manifest).unwrap();
assert_eq!(
json["all_image_file_names_as_regex"],
json!([".*\\.png", "screens/.*"])
);
}

#[test]
fn cli_managed_fields_override_sidecar_fields() {
let extra = serde_json::from_value(json!({
Expand Down
Loading
Loading