diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index c3308b9f0f5..3d06cf6b60e 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -11,13 +11,8 @@ jobs: steps: # actions/checkout@v2 - uses: actions/checkout@28c7f3d2b5162b5ddd3dfd9a45aa55eaf396478b - - uses: actions-rs/toolchain@b223206e28798aa3c3668bdd6409258e6dc29172 - with: - toolchain: nightly-2020-06-02 - default: false - components: rustfmt - name: Check style - run: cargo +nightly-2020-06-02 fmt -- --check + run: cargo fmt -- --check build-and-test: runs-on: ${{ matrix.os }} diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 99a95cb749a..00000000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "rust-analyzer.rustfmt.overrideCommand": [ - "rustup", - "run", - "nightly-2020-06-02", - "rustfmt" - ] -} diff --git a/README.adoc b/README.adoc index a43e488ac6a..3f442f2eaff 100644 --- a/README.adoc +++ b/README.adoc @@ -23,18 +23,15 @@ https://61.rfd.oxide.computer[RFD 61]. For design and API docs, see the https://rust.docs.corp.oxide.computer/oxide_api_prototype/[generated -documentation]. You can generate this yourself withfootnote:[Like many other -Rust crates, the rustdoc in this crate makes heavy use of -https://doc.rust-lang.org/rustdoc/unstable-features.html?highlight=link#linking-to-items-by-type[intra-document -linking], which requires a nightly version of `rustdoc`.]: +documentation]. You can generate this yourself with: [source,text] ---- -$ cargo +nightly doc --document-private-items +$ cargo doc --document-private-items ---- Note that `--document-private-items` is configured by default, so you can -actually just use `cargo +nightly doc`. +actually just use `cargo doc`. == Status @@ -59,8 +56,8 @@ See TODO.adoc for more info. You can **build and run the whole test suite** with `cargo test`. The test suite runs cleanly and should remain clean. -You can **format the code** using `cargo +nightly fmt`. Make sure to run this -before pushing changes. The CI checks that the code is correctly formatted. +You can **format the code** using `cargo fmt`. Make sure to run this before +pushing changes. The CI checks that the code is correctly formatted. To **run the system:** there are two executables: the `oxide_controller` (which is a real prototype backed by an in-memory store; this component manages an diff --git a/rustfmt.toml b/rustfmt.toml index 852e30fefcc..11297fdbee5 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -3,94 +3,4 @@ # --------------------------------------------------------------------------- max_width = 80 use_small_heuristics = "max" -unstable_features = true - -# -# --------------------------------------------------------------------------- -# Unstable features that we customize locally -# --------------------------------------------------------------------------- -# -# We would like to use "wrap_comments = true" and "comment_width = 80", but -# there are several issues with our use of it today, including rustfmt#4079 and -# rustfmt#4020. -# -# "overflow_delimited_expr" and "struct_lit_single_line" are both fairly minor, -# but improve readability. -# -format_strings = true -overflow_delimited_expr = true -struct_lit_single_line = false - -# -# --------------------------------------------------------------------------- -# Below are all other flags that we do NOT customize. We specify these -# explicitly here to minimize churn if the upstream defaults change. If you -# modify any of these, move them above this line! -# -# The following can be generated by starting with: -# -# rustfmt +nightly --print-config=default -# -# and removing anything that we've configured above. -# --------------------------------------------------------------------------- -# -hard_tabs = false -tab_spaces = 4 -newline_style = "Auto" -indent_style = "Block" -wrap_comments = false -format_code_in_doc_comments = false -comment_width = 80 -normalize_comments = false -normalize_doc_attributes = false -license_template_path = "" -format_macro_matchers = false -format_macro_bodies = true -empty_item_single_line = true -fn_single_line = false -where_single_line = false -imports_indent = "Block" -imports_layout = "Mixed" -merge_imports = false -reorder_imports = true -reorder_modules = true -reorder_impl_items = false -type_punctuation_density = "Wide" -space_before_colon = false -space_after_colon = true -spaces_around_ranges = false -binop_separator = "Front" -remove_nested_parens = true -combine_control_expr = true -struct_field_align_threshold = 0 -enum_discrim_align_threshold = 0 -match_arm_blocks = true -force_multiline_blocks = false -fn_args_layout = "Tall" -brace_style = "SameLineWhere" -control_brace_style = "AlwaysSameLine" -trailing_semicolon = true -trailing_comma = "Vertical" -match_block_trailing_comma = false -blank_lines_upper_bound = 1 -blank_lines_lower_bound = 0 edition = "2018" -version = "One" -inline_attribute_width = 0 -merge_derives = true -use_try_shorthand = false -use_field_init_shorthand = false -force_explicit_abi = true -condense_wildcard_suffixes = false -color = "Auto" -required_version = "1.4.15" -disable_all_formatting = false -skip_children = false -hide_parse_errors = false -error_on_line_overflow = false -error_on_unformatted = false -report_todo = "Never" -report_fixme = "Never" -ignore = [] -emit_mode = "Files" -make_backup = false diff --git a/src/api_error.rs b/src/api_error.rs index f28bf5b7c1b..585de5c5c70 100644 --- a/src/api_error.rs +++ b/src/api_error.rs @@ -110,9 +110,9 @@ impl ApiError { * include more information in the HttpErrorResponseBody. */ match error_response.error_code.as_deref() { - Some("InvalidRequest") => ApiError::InvalidRequest { - message: error_response.message, - }, + Some("InvalidRequest") => { + ApiError::InvalidRequest { message: error_response.message } + } _ => ApiError::InternalError { message: format!( "{}: unknown error from dependency: {:?}", @@ -131,10 +131,7 @@ impl From for HttpError { */ fn from(error: ApiError) -> HttpError { match error { - ApiError::ObjectNotFound { - type_name: t, - lookup_type: lt, - } => { + ApiError::ObjectNotFound { type_name: t, lookup_type: lt } => { if let LookupType::Other(message) = lt { HttpError::for_client_error( Some(String::from("ObjectNotFound")), @@ -160,10 +157,7 @@ impl From for HttpError { } } - ApiError::ObjectAlreadyExists { - type_name: t, - object_name: n, - } => { + ApiError::ObjectAlreadyExists { type_name: t, object_name: n } => { let message = format!("already exists: {} \"{}\"", t, n); HttpError::for_bad_request( Some(String::from("ObjectAlreadyExists")), @@ -171,17 +165,12 @@ impl From for HttpError { ) } - ApiError::InvalidRequest { - message, - } => HttpError::for_bad_request( + ApiError::InvalidRequest { message } => HttpError::for_bad_request( Some(String::from("InvalidRequest")), message, ), - ApiError::InvalidValue { - label, - message, - } => { + ApiError::InvalidValue { label, message } => { let message = format!("unsupported value for \"{}\": {}", label, message); HttpError::for_bad_request( @@ -190,13 +179,11 @@ impl From for HttpError { ) } - ApiError::InternalError { - message, - } => HttpError::for_internal_error(message), + ApiError::InternalError { message } => { + HttpError::for_internal_error(message) + } - ApiError::ServiceUnavailable { - message, - } => HttpError::for_unavail( + ApiError::ServiceUnavailable { message } => HttpError::for_unavail( Some(String::from("ServiceNotAvailable")), message, ), diff --git a/src/api_model.rs b/src/api_model.rs index 81f3dd5f6c3..5bee75cc274 100644 --- a/src/api_model.rs +++ b/src/api_model.rs @@ -320,14 +320,18 @@ pub enum ApiResourceType { impl Display for ApiResourceType { fn fmt(&self, f: &mut Formatter) -> FormatResult { - write!(f, "{}", match self { - ApiResourceType::Project => "project", - ApiResourceType::Disk => "disk", - ApiResourceType::DiskAttachment => "disk attachment", - ApiResourceType::Instance => "instance", - ApiResourceType::Rack => "rack", - ApiResourceType::Sled => "sled", - }) + write!( + f, + "{}", + match self { + ApiResourceType::Project => "project", + ApiResourceType::Disk => "disk", + ApiResourceType::DiskAttachment => "disk attachment", + ApiResourceType::Instance => "instance", + ApiResourceType::Rack => "rack", + ApiResourceType::Sled => "sled", + } + ) } } @@ -454,9 +458,7 @@ pub struct ApiProject { impl ApiObject for ApiProject { type View = ApiProjectView; fn to_view(&self) -> ApiProjectView { - ApiProjectView { - identity: self.identity.clone(), - } + ApiProjectView { identity: self.identity.clone() } } } @@ -946,9 +948,7 @@ pub struct ApiRack { impl ApiObject for ApiRack { type View = ApiRackView; fn to_view(&self) -> ApiRackView { - ApiRackView { - identity: self.identity.clone(), - } + ApiRackView { identity: self.identity.clone() } } } diff --git a/src/bin/sled_agent.rs b/src/bin/sled_agent.rs index 868d9d6a51d..afafa977830 100644 --- a/src/bin/sled_agent.rs +++ b/src/bin/sled_agent.rs @@ -84,9 +84,7 @@ async fn do_run() -> Result<(), CmdError> { bind_address: sa_addr, ..Default::default() }, - log: ConfigLogging::StderrTerminal { - level: ConfigLoggingLevel::Info, - }, + log: ConfigLogging::StderrTerminal { level: ConfigLoggingLevel::Info }, }; sa_run_server(&config).await.map_err(CmdError::Failure) diff --git a/src/http_pagination.rs b/src/http_pagination.rs index e81a5a883dc..d6e98766f35 100644 --- a/src/http_pagination.rs +++ b/src/http_pagination.rs @@ -193,18 +193,12 @@ where { let marker = match &pag_params.page { WhichPage::First(..) => None, - WhichPage::Next(ApiPageSelector { - last_seen, .. - }) => Some(last_seen), + WhichPage::Next(ApiPageSelector { last_seen, .. }) => Some(last_seen), }; let scan_params = S::from_query(pag_params)?; let direction = scan_params.direction(); - Ok(DataPageParams { - marker, - direction, - limit, - }) + Ok(DataPageParams { marker, direction, limit }) } /* @@ -251,9 +245,7 @@ impl ScanParams for ApiScanByName { ) -> Result<&Self, HttpError> { Ok(match p.page { WhichPage::First(ref scan_params) => scan_params, - WhichPage::Next(ApiPageSelector { - ref scan, .. - }) => scan, + WhichPage::Next(ApiPageSelector { ref scan, .. }) => scan, }) } } @@ -300,9 +292,7 @@ impl ScanParams for ApiScanById { fn from_query(p: &ApiPaginatedById) -> Result<&Self, HttpError> { Ok(match p.page { WhichPage::First(ref scan_params) => scan_params, - WhichPage::Next(ApiPageSelector { - ref scan, .. - }) => scan, + WhichPage::Next(ApiPageSelector { ref scan, .. }) => scan, }) } } @@ -463,11 +453,7 @@ fn data_page_params_nameid_name_limit<'a>( */ Some(ApiNameOrIdMarker::Id(_)) => return Err(bad_token_error()), }; - Ok(DataPageParams { - limit, - direction, - marker, - }) + Ok(DataPageParams { limit, direction, marker }) } /** @@ -497,11 +483,7 @@ fn data_page_params_nameid_id_limit<'a>( */ Some(ApiNameOrIdMarker::Name(_)) => return Err(bad_token_error()), }; - Ok(DataPageParams { - limit, - direction, - marker, - }) + Ok(DataPageParams { limit, direction, marker }) } #[cfg(test)] @@ -596,18 +578,13 @@ mod test { */ #[test] fn test_pagination_examples() { - let scan_by_id = ApiScanById { - sort_by: ApiIdSortMode::IdAscending, - }; - let scan_by_name = ApiScanByName { - sort_by: ApiNameSortMode::NameAscending, - }; - let scan_by_nameid_name = ApiScanByNameOrId { - sort_by: ApiNameOrIdSortMode::NameAscending, - }; - let scan_by_nameid_id = ApiScanByNameOrId { - sort_by: ApiNameOrIdSortMode::IdAscending, - }; + let scan_by_id = ApiScanById { sort_by: ApiIdSortMode::IdAscending }; + let scan_by_name = + ApiScanByName { sort_by: ApiNameSortMode::NameAscending }; + let scan_by_nameid_name = + ApiScanByNameOrId { sort_by: ApiNameOrIdSortMode::NameAscending }; + let scan_by_nameid_id = + ApiScanByNameOrId { sort_by: ApiNameOrIdSortMode::IdAscending }; let id: Uuid = "61a78113-d3c6-4b35-a410-23e9eae64328".parse().unwrap(); let name = ApiName::try_from(String::from("bort")).unwrap(); let examples = vec![ @@ -756,9 +733,7 @@ mod test { * the results page was properly generated. */ assert_eq!(S::from_query(&p1).unwrap(), scan); - if let WhichPage::Next(ApiPageSelector { - ref last_seen, .. - }) = p1.page + if let WhichPage::Next(ApiPageSelector { ref last_seen, .. }) = p1.page { assert_eq!(last_seen, itemlast_marker); } else { @@ -775,9 +750,7 @@ mod test { #[test] fn test_scan_by_name() { /* Start with the common battery of tests. */ - let scan = ApiScanByName { - sort_by: ApiNameSortMode::NameAscending, - }; + let scan = ApiScanByName { sort_by: ApiNameSortMode::NameAscending }; let list = list_of_things(); let (p0, p1) = test_scan_param_common( @@ -816,9 +789,7 @@ mod test { #[test] fn test_scan_by_id() { /* Start with the common battery of tests. */ - let scan = ApiScanById { - sort_by: ApiIdSortMode::IdAscending, - }; + let scan = ApiScanById { sort_by: ApiIdSortMode::IdAscending }; let list = list_of_things(); let (p0, p1) = test_scan_param_common( @@ -880,9 +851,8 @@ mod test { #[test] fn test_scan_by_nameid_name() { /* Start with the common battery of tests. */ - let scan = ApiScanByNameOrId { - sort_by: ApiNameOrIdSortMode::NameDescending, - }; + let scan = + ApiScanByNameOrId { sort_by: ApiNameOrIdSortMode::NameDescending }; assert_eq!(pagination_field_for_scan_params(&scan), ApiPagField::Name); assert_eq!(scan.direction(), PaginationOrder::Descending); @@ -899,9 +869,7 @@ mod test { "sort_by=name-descending", &thing0_marker, &thinglast_marker, - &ApiScanByNameOrId { - sort_by: ApiNameOrIdSortMode::NameAscending, - }, + &ApiScanByNameOrId { sort_by: ApiNameOrIdSortMode::NameAscending }, ); /* Verify data pages based on the query params. */ @@ -924,9 +892,8 @@ mod test { #[test] fn test_scan_by_nameid_id() { /* Start with the common battery of tests. */ - let scan = ApiScanByNameOrId { - sort_by: ApiNameOrIdSortMode::IdAscending, - }; + let scan = + ApiScanByNameOrId { sort_by: ApiNameOrIdSortMode::IdAscending }; assert_eq!(pagination_field_for_scan_params(&scan), ApiPagField::Id); assert_eq!(scan.direction(), PaginationOrder::Ascending); @@ -941,9 +908,7 @@ mod test { "sort_by=id-ascending", &thing0_marker, &thinglast_marker, - &ApiScanByNameOrId { - sort_by: ApiNameOrIdSortMode::NameAscending, - }, + &ApiScanByNameOrId { sort_by: ApiNameOrIdSortMode::NameAscending }, ); /* Verify data pages based on the query params. */ diff --git a/src/oxide_controller/config.rs b/src/oxide_controller/config.rs index e268a9617d8..901629291b3 100644 --- a/src/oxide_controller/config.rs +++ b/src/oxide_controller/config.rs @@ -36,19 +36,13 @@ pub enum LoadErrorKind { impl From<(PathBuf, std::io::Error)> for LoadError { fn from((path, err): (PathBuf, std::io::Error)) -> Self { - LoadError { - path, - kind: LoadErrorKind::Io(err), - } + LoadError { path, kind: LoadErrorKind::Io(err) } } } impl From<(PathBuf, toml::de::Error)> for LoadError { fn from((path, err): (PathBuf, toml::de::Error)) -> Self { - LoadError { - path, - kind: LoadErrorKind::Parse(err), - } + LoadError { path, kind: LoadErrorKind::Parse(err) } } } @@ -220,20 +214,27 @@ mod test { ) .unwrap(); - assert_eq!(config, ConfigController { - dropshot_external: ConfigDropshot { - bind_address: "10.1.2.3:4567".parse::().unwrap(), - ..Default::default() - }, - dropshot_internal: ConfigDropshot { - bind_address: "10.1.2.3:4568".parse::().unwrap(), - ..Default::default() - }, - log: ConfigLogging::File { - level: ConfigLoggingLevel::Debug, - if_exists: ConfigLoggingIfExists::Fail, - path: "/nonexistent/path".to_string() + assert_eq!( + config, + ConfigController { + dropshot_external: ConfigDropshot { + bind_address: "10.1.2.3:4567" + .parse::() + .unwrap(), + ..Default::default() + }, + dropshot_internal: ConfigDropshot { + bind_address: "10.1.2.3:4568" + .parse::() + .unwrap(), + ..Default::default() + }, + log: ConfigLogging::File { + level: ConfigLoggingLevel::Debug, + if_exists: ConfigLoggingIfExists::Fail, + path: "/nonexistent/path".to_string() + } } - }); + ); } } diff --git a/src/oxide_controller/oxide_controller.rs b/src/oxide_controller/oxide_controller.rs index ebdc71d8118..22e64232173 100644 --- a/src/oxide_controller/oxide_controller.rs +++ b/src/oxide_controller/oxide_controller.rs @@ -526,9 +526,7 @@ impl OxideController { let said = &instance.runtime.sled_uuid; Ok(Arc::clone(sled_agents.get(said).ok_or_else(|| { let message = format!("no sled agent for sled_uuid \"{}\"", said); - ApiError::ServiceUnavailable { - message, - } + ApiError::ServiceUnavailable { message } })?)) } @@ -784,9 +782,7 @@ impl OxideController { String::from(disk.identity.name.clone()), disk_status ); - Err(ApiError::InvalidRequest { - message, - }) + Err(ApiError::InvalidRequest { message }) } match &disk.runtime.disk_state { @@ -1050,9 +1046,7 @@ impl OxideController { * and in that case, we'd need some async task for cleaning these * up. */ - Err(ApiError::ObjectNotFound { - .. - }) => { + Err(ApiError::ObjectNotFound { .. }) => { warn!(log, "non-existent instance updated by sled agent"; "instance_id" => %id, "new_state" => %new_runtime_state.run_state); @@ -1107,9 +1101,7 @@ impl OxideController { * and in that case, we'd need some async task for cleaning these * up. */ - Err(ApiError::ObjectNotFound { - .. - }) => { + Err(ApiError::ObjectNotFound { .. }) => { warn!(log, "non-existent disk updated by sled agent"; "instance_id" => %id, "new_state" => ?new_state); diff --git a/src/sled_agent/mod.rs b/src/sled_agent/mod.rs index 4841cdac703..0181d3578d4 100644 --- a/src/sled_agent/mod.rs +++ b/src/sled_agent/mod.rs @@ -91,9 +91,12 @@ impl SledAgentServer { loop { debug!(log, "contacting server controller"); let result = controller_client - .notify_sled_agent_online(config.id, ApiSledAgentStartupInfo { - sa_address: http_server.local_addr(), - }) + .notify_sled_agent_online( + config.id, + ApiSledAgentStartupInfo { + sa_address: http_server.local_addr(), + }, + ) .await; match result { Ok(()) => break, @@ -110,11 +113,7 @@ impl SledAgentServer { info!(log, "contacted server controller"); - Ok(SledAgentServer { - sled_agent, - http_server, - join_handle, - }) + Ok(SledAgentServer { sled_agent, http_server, join_handle }) } /** diff --git a/src/sled_agent/sled_agent.rs b/src/sled_agent/sled_agent.rs index 72679049ded..9981f50776e 100644 --- a/src/sled_agent/sled_agent.rs +++ b/src/sled_agent/sled_agent.rs @@ -1576,10 +1576,7 @@ mod test { let error = disk .transition(ApiDiskStateRequested::Attached(id2.clone())) .unwrap_err(); - if let ApiError::InvalidRequest { - message, - } = error - { + if let ApiError::InvalidRequest { message } = error { assert_eq!("disk is already attached", message); } else { panic!("unexpected error type"); @@ -1635,10 +1632,7 @@ mod test { let error = disk .transition(ApiDiskStateRequested::Attached(id.clone())) .unwrap_err(); - if let ApiError::InvalidRequest { - message, - } = error - { + if let ApiError::InvalidRequest { message } = error { assert_eq!("cannot attach while detaching", message); } else { panic!("unexpected error type"); diff --git a/src/sled_agent/sled_agent_client.rs b/src/sled_agent/sled_agent_client.rs index 1d83072c6d8..a52c60e95da 100644 --- a/src/sled_agent/sled_agent_client.rs +++ b/src/sled_agent/sled_agent_client.rs @@ -95,11 +95,8 @@ impl SledAgentClient { ) -> Result { let path = format!("/disks/{}", disk_id); let body = Body::from( - serde_json::to_string(&DiskEnsureBody { - initial_runtime, - target, - }) - .unwrap(), + serde_json::to_string(&DiskEnsureBody { initial_runtime, target }) + .unwrap(), ); let mut response = self.client.request(Method::PUT, path.as_str(), body).await?; diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 7a1edfe69b0..4c67569d283 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -108,9 +108,7 @@ pub async fn start_sled_agent( ..Default::default() }, /* TODO-cleanup this is unused */ - log: ConfigLogging::StderrTerminal { - level: ConfigLoggingLevel::Debug, - }, + log: ConfigLogging::StderrTerminal { level: ConfigLoggingLevel::Debug }, }; SledAgentServer::start(&config, &log).await diff --git a/tests/test_disks.rs b/tests/test_disks.rs index 676134a3b5b..6394a7c5fd3 100644 --- a/tests/test_disks.rs +++ b/tests/test_disks.rs @@ -51,14 +51,17 @@ async fn test_disks() { /* Create a project for testing. */ let project_name = "springfield-squidport-disks"; let url_disks = format!("/projects/{}/disks", project_name); - let project: ApiProjectView = - objects_post(&client, "/projects", ApiProjectCreateParams { + let project: ApiProjectView = objects_post( + &client, + "/projects", + ApiProjectCreateParams { identity: ApiIdentityMetadataCreateParams { name: ApiName::try_from(project_name).unwrap(), description: "a pier".to_string(), }, - }) - .await; + }, + ) + .await; /* List disks. There aren't any yet. */ let disks = disks_list(&client, &url_disks).await; @@ -126,8 +129,10 @@ async fn test_disks() { /* Create an instance to attach the disk. */ let url_instances = format!("/projects/{}/instances", project_name); - let instance: ApiInstanceView = - objects_post(&client, &url_instances, ApiInstanceCreateParams { + let instance: ApiInstanceView = objects_post( + &client, + &url_instances, + ApiInstanceCreateParams { identity: ApiIdentityMetadataCreateParams { name: ApiName::try_from("just-rainsticks").unwrap(), description: String::from("sells rainsticks"), @@ -136,8 +141,9 @@ async fn test_disks() { memory: ApiByteCount::from_mebibytes(256), boot_disk_size: ApiByteCount::from_gibibytes(1), hostname: String::from("rainsticks"), - }) - .await; + }, + ) + .await; /* * Verify that there are no disks attached to the instance, and specifically @@ -244,8 +250,10 @@ async fn test_disks() { * Create a second instance and try to attach the disk to that. This should * fail and the disk should remain attached to the first instance. */ - let instance2: ApiInstanceView = - objects_post(&client, &url_instances, ApiInstanceCreateParams { + let instance2: ApiInstanceView = objects_post( + &client, + &url_instances, + ApiInstanceCreateParams { identity: ApiIdentityMetadataCreateParams { name: ApiName::try_from("instance2").unwrap(), description: String::from("instance2"), @@ -254,8 +262,9 @@ async fn test_disks() { memory: ApiByteCount::from_mebibytes(256), boot_disk_size: ApiByteCount::from_gibibytes(1), hostname: String::from("instance2"), - }) - .await; + }, + ) + .await; let url_instance2_disk = format!( "/projects/{}/instances/{}/disks/{}", project_name, diff --git a/tests/test_instances.rs b/tests/test_instances.rs index 60e266f6e19..ce621a5c1ff 100644 --- a/tests/test_instances.rs +++ b/tests/test_instances.rs @@ -44,14 +44,17 @@ async fn test_instances() { /* Create a project that we'll use for testing. */ let project_name = "springfield-squidport"; let url_instances = format!("/projects/{}/instances", project_name); - let _: ApiProjectView = - objects_post(&client, "/projects", ApiProjectCreateParams { + let _: ApiProjectView = objects_post( + &client, + "/projects", + ApiProjectCreateParams { identity: ApiIdentityMetadataCreateParams { name: ApiName::try_from(project_name).unwrap(), description: "a pier".to_string(), }, - }) - .await; + }, + ) + .await; /* List instances. There aren't any yet. */ let instances = instances_list(&client, &url_instances).await; @@ -425,11 +428,15 @@ async fn instance_post( instance_url: &str, which: InstanceOp, ) -> ApiInstanceView { - let url = format!("{}/{}", instance_url, match which { - InstanceOp::Start => "start", - InstanceOp::Stop => "stop", - InstanceOp::Reboot => "reboot", - }); + let url = format!( + "{}/{}", + instance_url, + match which { + InstanceOp::Start => "start", + InstanceOp::Stop => "stop", + InstanceOp::Reboot => "reboot", + } + ); let mut response = client .make_request_with_body( Method::POST,