Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
sunshowers committed Nov 19, 2023
1 parent 72f2e45 commit 0434272
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions nexus/tests/integration_tests/updates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,22 @@ const UPDATE_COMPONENT: &'static str = "omicron-test-component";
#[tokio::test]
async fn test_update_end_to_end() {
let mut config = load_test_config();
let logctx = LogContext::new("test_update_end_to_end", &config.pkg.log);

// build the TUF repo
let rng = SystemRandom::new();
let tuf_repo = new_tuf_repo(&rng).await;
slog::info!(
logctx.log,
"TUF repo created at {}",
tuf_repo.path().display()
);

// serve it over HTTP
let dropshot_config = Default::default();
let mut api = ApiDescription::new();
api.register(static_content).unwrap();
let context = FileServerContext { base: tuf_repo.path().to_owned() };
let logctx = LogContext::new("test_update_end_to_end", &config.pkg.log);
let server =
HttpServerStarter::new(&dropshot_config, api, context, &logctx.log)
.unwrap()
Expand Down Expand Up @@ -123,9 +128,14 @@ async fn static_content(
for component in path.into_inner().path {
fs_path.push(component);
}
let body = tokio::fs::read(fs_path)
.await
.map_err(|e| HttpError::for_bad_request(None, e.to_string()))?;
let body = tokio::fs::read(fs_path).await.map_err(|e| {
// tough 0.15+ depend on ENOENT being translated into 404.
if e.kind() == std::io::ErrorKind::NotFound {
HttpError::for_not_found(None, e.to_string())
} else {
HttpError::for_bad_request(None, e.to_string())
}
})?;
Ok(Response::builder().status(StatusCode::OK).body(body.into())?)
}

Expand Down

0 comments on commit 0434272

Please sign in to comment.