Skip to content

Commit

Permalink
update test should not succeed by accident
Browse files Browse the repository at this point in the history
  • Loading branch information
davepacheco committed Apr 13, 2022
1 parent 4812772 commit b0bf05e
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion nexus/tests/integration_tests/updates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,19 @@ use tough::key_source::KeySource;
use tough::schema::{KeyHolder, RoleKeys, RoleType, Root};
use tough::sign::Sign;

const UPDATE_IMAGE_PATH: &'static str = "/var/tmp/zones/cockroachdb";

#[tokio::test]
async fn test_update_end_to_end() {
let mut config = load_test_config();

// If the output file already exists, record the mtime.
let mtime: Option<_> = match tokio::fs::metadata(UPDATE_IMAGE_PATH).await {
Ok(metadata) => Some(metadata.modified().unwrap()),
Err(e) if matches!(e.kind(), std::io::ErrorKind::NotFound) => None,
Err(e) => panic!("failed to stat {:?}: {:?}", UPDATE_IMAGE_PATH, e),
};

// build the TUF repo
let rng = SystemRandom::new();
let tuf_repo = new_tuf_repo(&rng);
Expand Down Expand Up @@ -83,8 +92,14 @@ async fn test_update_end_to_end() {
.unwrap();

// check sled agent did the thing
if let Some(old_mtime) = mtime {
let new_metadata = tokio::fs::metadata(UPDATE_IMAGE_PATH)
.await
.expect("failed to stat file after it was previously found");
assert!(old_mtime < new_metadata.modified().unwrap());
}
assert_eq!(
std::fs::read("/var/tmp/zones/cockroachdb").unwrap(),
tokio::fs::read(UPDATE_IMAGE_PATH).await.unwrap(),
TARGET_CONTENTS
);

Expand Down

0 comments on commit b0bf05e

Please sign in to comment.