Skip to content

Commit

Permalink
Merge pull request #879 from cgwalters/stream-from-container-prep
Browse files Browse the repository at this point in the history
Stream from container prep
  • Loading branch information
Luca Bruno authored Nov 3, 2022
2 parents a503193 + f1c123a commit 2dbc43c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 10 additions & 5 deletions src/rpm_ostree/cli_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,16 @@ pub fn parse_booted(status: &StatusJson) -> Result<Release> {
Ok(json.into_release())
}

fn fedora_coreos_stream_from_deployment(deploy: &DeploymentJson) -> Result<String> {
let stream = deploy.base_metadata.stream.as_str();
ensure!(!stream.is_empty(), "empty stream value");
Ok(stream.to_string())
}

/// Parse updates stream for booted deployment from status object.
pub fn parse_booted_updates_stream(status: &StatusJson) -> Result<String> {
let json = booted_json(status)?;
ensure!(!json.base_metadata.stream.is_empty(), "empty stream value");
Ok(json.base_metadata.stream)
fedora_coreos_stream_from_deployment(&json)
}

/// Parse pending deployment from status object.
Expand All @@ -105,8 +110,7 @@ pub fn parse_pending_deployment(status: &StatusJson) -> Result<Option<(Release,
match staged {
None => Ok(None),
Some(json) => {
let stream = json.base_metadata.stream.clone();
ensure!(!stream.is_empty(), "empty stream value");
let stream = fedora_coreos_stream_from_deployment(&json)?;
let release = json.into_release();
Ok(Some((release, stream)))
}
Expand Down Expand Up @@ -239,6 +243,7 @@ mod tests {
fn mock_booted_updates_stream() {
let status = mock_status("tests/fixtures/rpm-ostree-status.json").unwrap();
let booted = booted_json(&status).unwrap();
assert_eq!(booted.base_metadata.stream, "testing-devel");
let stream = fedora_coreos_stream_from_deployment(&booted).unwrap();
assert_eq!(stream, "testing-devel");
}
}
2 changes: 1 addition & 1 deletion src/weekly/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ mod tests {
Err(_) => Duration::from_secs(1),
};
prop_assert!(res.as_secs() > 0);
prop_assert!((res.as_secs() / 60) < MAX_WEEKLY_MINS.into());
prop_assert!((res.as_secs() / 60) < u64::from(MAX_WEEKLY_MINS));
}

#[test]
Expand Down

0 comments on commit 2dbc43c

Please sign in to comment.