From 3b2506691f89afab3acddd7b62afac8b601daf23 Mon Sep 17 00:00:00 2001 From: gnalh Date: Fri, 17 Jan 2025 02:20:13 +0000 Subject: [PATCH] init --- Cargo.lock | 22 +++-- api/Cargo.toml | 27 ++++++ {cli/src/api_client => api/src}/call_api.rs | 2 +- .../api_client/mod.rs => api/src/client.rs | 53 ++++++----- api/src/lib.rs | 69 +------------- api/src/message.rs | 90 +++++++++++++++++++ cli-tests/src/quarantine.rs | 12 ++- cli-tests/src/upload.rs | 2 +- cli/Cargo.toml | 9 +- cli/src/context.rs | 8 +- cli/src/context_quarantine.rs | 27 +++--- cli/src/lib.rs | 1 - cli/src/upload_command.rs | 10 +-- test_utils/src/mock_server.rs | 23 ++--- 14 files changed, 210 insertions(+), 145 deletions(-) rename {cli/src/api_client => api/src}/call_api.rs (98%) rename cli/src/api_client/mod.rs => api/src/client.rs (90%) create mode 100644 api/src/message.rs diff --git a/Cargo.lock b/Cargo.lock index bcc6d650..013a33ab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -107,18 +107,30 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.94" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1fd03a028ef38ba2276dce7e33fcd6369c158a1bca17946c4b1b701891c1ff7" +checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04" [[package]] name = "api" version = "0.1.0" dependencies = [ + "anyhow", + "axum 0.7.9", "bundle", + "constants", "context", + "http 1.2.0", + "lazy_static", + "log", + "reqwest", + "sentry", "serde", "serde_json", + "tempfile", + "test_utils", + "tokio", + "tokio-retry", ] [[package]] @@ -2594,9 +2606,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.22" +version = "0.4.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" +checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f" dependencies = [ "value-bag", ] @@ -4742,7 +4754,6 @@ version = "0.0.0" dependencies = [ "anyhow", "api", - "axum 0.7.9", "bundle", "chrono", "clap", @@ -4755,7 +4766,6 @@ dependencies = [ "exitcode", "glob", "http 1.2.0", - "lazy_static", "log", "openssl", "openssl-src", diff --git a/api/Cargo.toml b/api/Cargo.toml index 85d4dd75..f5ce6a80 100644 --- a/api/Cargo.toml +++ b/api/Cargo.toml @@ -8,3 +8,30 @@ context = { path = "../context" } serde = { version = "1.0.215", default-features = false, features = ["derive"] } serde_json = "1.0.133" bundle = { path = "../bundle" } +sentry = { version = "0.34.0", features = ["debug-images"] } +tokio = { version = "*", default-features = false, features = [ + "rt-multi-thread", + "macros", +] } +anyhow = "1.0.44" +reqwest = { version = "0.12.5", default-features = false, features = [ + "rustls-tls-native-roots", + "stream", + "json", +] } +log = "0.4.14" +http = "1.1.0" +tokio-retry = { version = "0.3", default-features = false } +constants = { version = "0.0.0", path = "../constants" } + +[dev-dependencies] +axum = { version = "0.7.5", features = ["macros"] } +tokio = { version = "*", default-features = false, features = [ + "rt-multi-thread", + "macros", + "test-util", + "time", +] } +tempfile = "3.2.0" +test_utils = { path = "../test_utils" } +lazy_static = "1.5.0" diff --git a/cli/src/api_client/call_api.rs b/api/src/call_api.rs similarity index 98% rename from cli/src/api_client/call_api.rs rename to api/src/call_api.rs index 5206457b..eb2a2277 100644 --- a/cli/src/api_client/call_api.rs +++ b/api/src/call_api.rs @@ -74,7 +74,7 @@ where } }); - let result = Retry::spawn(default_delay(), || (&mut self.action).run()).await; + let result = Retry::spawn(default_delay(), || self.action.run()).await; report_slow_progress_handle.abort(); check_progress_handle.abort(); diff --git a/cli/src/api_client/mod.rs b/api/src/client.rs similarity index 90% rename from cli/src/api_client/mod.rs rename to api/src/client.rs index f121a0b8..0a710e28 100644 --- a/cli/src/api_client/mod.rs +++ b/api/src/client.rs @@ -1,15 +1,13 @@ use std::path::Path; +use crate::call_api::CallApi; +use crate::message; use anyhow::Context; -use api; -use call_api::CallApi; use constants::{DEFAULT_ORIGIN, TRUNK_PUBLIC_API_ADDRESS_ENV}; use http::{header::HeaderMap, HeaderValue}; use reqwest::{header, Client, Response, StatusCode}; use tokio::fs; -mod call_api; - pub struct ApiClient { host: String, s3_client: Client, @@ -26,7 +24,7 @@ impl ApiClient { if api_token.trim().is_empty() { return Err(anyhow::anyhow!("Trunk API token is required.")); } - let api_token_header_value = HeaderValue::from_str(&api_token) + let api_token_header_value = HeaderValue::from_str(api_token) .map_err(|_| anyhow::Error::msg("Trunk API token is not ASCII"))?; let host = std::env::var(TRUNK_PUBLIC_API_ADDRESS_ENV) @@ -69,7 +67,10 @@ impl ApiClient { }) } - pub async fn create_trunk_repo(&self, request: &api::CreateRepoRequest) -> anyhow::Result<()> { + pub async fn create_repo( + &self, + request: &message::CreateRepoRequest, + ) -> anyhow::Result { CallApi { action: || async { let response = self @@ -83,8 +84,13 @@ impl ApiClient { &response, CheckUnauthorized::Check, CheckNotFound::DoNotCheck, - |_| format!("Failed to create repo."), - ) + |_| "Failed to create repo.".to_string(), + )?; + + response + .json::() + .await + .context("Failed to get response body as json.") }, log_progress_message: |time_elapsed, _| { format!("Communicating with Trunk services is taking longer than expected. It has taken {} seconds so far.", time_elapsed.as_secs()) @@ -97,10 +103,10 @@ impl ApiClient { .await } - pub async fn create_bundle_upload_intent( + pub async fn create_bundle_upload( &self, - request: &api::CreateBundleUploadRequest, - ) -> anyhow::Result { + request: &message::CreateBundleUploadRequest, + ) -> anyhow::Result { CallApi { action: || async { let response = self @@ -118,7 +124,7 @@ impl ApiClient { )?; response - .json::() + .json::() .await .context("Failed to get response body as json.") }, @@ -135,8 +141,8 @@ impl ApiClient { pub async fn get_quarantining_config( &self, - request: &api::GetQuarantineBulkTestStatusRequest, - ) -> anyhow::Result { + request: &message::GetQuarantineConfigRequest, + ) -> anyhow::Result { CallApi { action: || async { let response = self @@ -160,7 +166,7 @@ impl ApiClient { )?; response - .json::() + .json::() .await .context("Failed to get response body as json.") }, @@ -211,10 +217,10 @@ impl ApiClient { .await } - pub async fn update_bundle_upload_status( + pub async fn update_bundle_upload( &self, - request: &api::UpdateBundleUploadRequest, - ) -> anyhow::Result<()> { + request: &message::UpdateBundleUploadRequest, + ) -> anyhow::Result { CallApi { action: || async { let response = self @@ -234,7 +240,11 @@ impl ApiClient { request.upload_status ) }, - ) + )?; + response + .json::() + .await + .context("Failed to get response body as json.") }, log_progress_message: |time_elapsed, _| { format!("Communicating with Trunk services is taking longer than expected. It has taken {} seconds so far.", time_elapsed.as_secs()) @@ -292,6 +302,7 @@ fn status_code_help String>( mod tests { use std::{env, time::Duration}; + use crate::message; use axum::{http::StatusCode, response::Response}; use tempfile::NamedTempFile; use test_utils::{mock_logger, mock_sentry, mock_server::MockServerBuilder}; @@ -329,8 +340,8 @@ mod tests { .unwrap() .iter() .filter(|(_, message)| message.starts_with("Uploading bundle to S3")) - .cloned() .take(2) + .cloned() .collect::>(); assert_eq!(first_two_slow_s3_upload_logs, vec![ (log::Level::Info, String::from("Uploading bundle to S3 is taking longer than expected. It has taken 2 seconds so far.")), @@ -368,7 +379,7 @@ mod tests { let api_client = ApiClient::new(String::from("mock-token")).unwrap(); assert!(api_client - .get_quarantining_config(&api::GetQuarantineBulkTestStatusRequest { + .get_quarantining_config(&message::GetQuarantineConfigRequest { repo: context::repo::RepoUrlParts { host: String::from("host"), owner: String::from("owner"), diff --git a/api/src/lib.rs b/api/src/lib.rs index 531e446a..da4f8fa9 100644 --- a/api/src/lib.rs +++ b/api/src/lib.rs @@ -1,66 +1,3 @@ -use bundle::Test; -use context::repo::RepoUrlParts; -use serde::{Deserialize, Serialize}; - -#[derive(Debug, Serialize, Clone, Deserialize, PartialEq, Eq)] -pub struct CreateBundleUploadRequest { - pub repo: RepoUrlParts, - #[serde(rename = "orgUrlSlug")] - pub org_url_slug: String, - #[serde(rename = "clientVersion")] - pub client_version: String, -} - -#[derive(Debug, Serialize, Clone, Deserialize)] -pub struct CreateBundleUploadResponse { - pub id: String, - #[serde(rename = "idV2")] - pub id_v2: String, - pub url: String, - pub key: String, -} - -#[derive(Debug, Serialize, Clone, Deserialize, PartialEq, Eq)] -pub enum BundleUploadStatus { - #[serde(rename = "PENDING")] - Pending, - #[serde(rename = "UPLOAD_COMPLETE")] - UploadComplete, - #[serde(rename = "UPLOAD_FAILED")] - UploadFailed, - #[serde(rename = "DRY_RUN")] - DryRun, -} - -#[derive(Debug, Serialize, Clone, Deserialize, PartialEq, Eq)] -pub struct UpdateBundleUploadRequest { - pub id: String, - #[serde(rename = "uploadStatus")] - pub upload_status: BundleUploadStatus, -} - -#[derive(Debug, Serialize, Clone, Deserialize, PartialEq, Eq)] -pub struct CreateRepoRequest { - pub repo: RepoUrlParts, - #[serde(rename = "orgUrlSlug")] - pub org_url_slug: String, - #[serde(rename = "remoteUrls")] - pub remote_urls: Vec, -} - -#[derive(Debug, Serialize, Clone, Deserialize, PartialEq, Eq)] -pub struct GetQuarantineBulkTestStatusRequest { - pub repo: RepoUrlParts, - #[serde(rename = "orgUrlSlug")] - pub org_url_slug: String, - #[serde(rename = "testIdentifiers")] - pub test_identifiers: Vec, -} - -#[derive(Debug, Serialize, Clone, Deserialize, Default)] -pub struct QuarantineConfig { - #[serde(rename = "isDisabled")] - pub is_disabled: bool, - #[serde(rename = "testIds")] - pub quarantined_tests: Vec, -} +mod call_api; +pub mod client; +pub mod message; diff --git a/api/src/message.rs b/api/src/message.rs new file mode 100644 index 00000000..3773bbf6 --- /dev/null +++ b/api/src/message.rs @@ -0,0 +1,90 @@ +use bundle::Test; +use context::repo::RepoUrlParts; +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Serialize, Clone, Deserialize, PartialEq, Eq)] +pub enum BundleUploadStatus { + #[serde(rename = "PENDING")] + Pending, + #[serde(rename = "UPLOAD_COMPLETE")] + UploadComplete, + #[serde(rename = "UPLOAD_FAILED")] + UploadFailed, + #[serde(rename = "DRY_RUN")] + DryRun, +} + +#[derive(Debug, Serialize, Clone, Deserialize, PartialEq, Eq)] +pub struct CreateBundleUploadRequest { + pub repo: RepoUrlParts, + #[serde(rename = "orgUrlSlug")] + pub org_url_slug: String, + #[serde(rename = "clientVersion")] + pub client_version: String, +} + +#[derive(Debug, Serialize, Clone, Deserialize)] +pub struct CreateBundleUploadResponse { + pub id: String, + #[serde(rename = "idV2")] + pub id_v2: String, + pub url: String, + pub key: String, +} + +#[derive(Debug, Serialize, Clone, Deserialize, Default)] +pub struct GetQuarantineConfigResponse { + #[serde(rename = "isDisabled")] + pub is_disabled: bool, + #[serde(rename = "testIds")] + pub quarantined_tests: Vec, +} + +#[derive(Debug, Serialize, Clone, Deserialize, PartialEq, Eq)] +pub struct GetQuarantineConfigRequest { + pub repo: RepoUrlParts, + #[serde(rename = "orgUrlSlug")] + pub org_url_slug: String, + #[serde(rename = "testIdentifiers")] + pub test_identifiers: Vec, +} + +#[derive(Debug, Serialize, Clone, Deserialize, PartialEq, Eq)] +pub struct CreateRepoRequest { + pub repo: RepoUrlParts, + #[serde(rename = "orgUrlSlug")] + pub org_url_slug: String, + #[serde(rename = "remoteUrls")] + pub remote_urls: Vec, +} + +#[derive(Debug, Serialize, Clone, Deserialize, PartialEq, Eq)] +pub struct CreateRepoResponse {} + +#[derive(Debug, Serialize, Clone, Deserialize, PartialEq, Eq)] +pub struct UpdateBundleUploadRequest { + pub id: String, + #[serde(rename = "uploadStatus")] + pub upload_status: BundleUploadStatus, +} + +#[derive(Debug, Serialize, Clone, Deserialize, PartialEq, Eq)] +pub struct UpdateBundleUploadResponse {} + +#[derive(Debug, Serialize, Clone, Deserialize, PartialEq, Eq)] +pub struct CreateBundleUploadIntentRequest { + pub repo: RepoUrlParts, + #[serde(rename = "orgUrlSlug")] + pub org_url_slug: String, + #[serde(rename = "clientVersion")] + pub client_version: String, +} + +#[derive(Debug, Serialize, Clone, Deserialize, PartialEq, Eq)] +pub struct CreateBundleUploadIntentResponse { + pub repo: RepoUrlParts, + #[serde(rename = "orgUrlSlug")] + pub org_url_slug: String, + #[serde(rename = "clientVersion")] + pub client_version: String, +} diff --git a/cli-tests/src/quarantine.rs b/cli-tests/src/quarantine.rs index 244a7a97..a18c41a1 100644 --- a/cli-tests/src/quarantine.rs +++ b/cli-tests/src/quarantine.rs @@ -3,9 +3,9 @@ use std::sync::{Arc, Mutex}; use crate::utils::{ generate_mock_codeowners, generate_mock_git_repo, generate_mock_valid_junit_xmls, CARGO_RUN, }; -use api::{ - CreateBundleUploadRequest, CreateBundleUploadResponse, GetQuarantineBulkTestStatusRequest, - QuarantineConfig, +use api::message::{ + CreateBundleUploadRequest, CreateBundleUploadResponse, GetQuarantineConfigRequest, + GetQuarantineConfigResponse, }; use assert_cmd::Command; use axum::{extract::State, Json}; @@ -35,9 +35,7 @@ async fn quarantines_tests_regardless_of_upload() { Arc::new(Mutex::new(QuarantineConfigResponse::None)); } mock_server_builder.set_get_quarantining_config_handler( - |Json(get_quarantine_bulk_test_status_request): Json< - GetQuarantineBulkTestStatusRequest, - >| { + |Json(get_quarantine_bulk_test_status_request): Json| { let mut test_ids = get_quarantine_bulk_test_status_request .test_identifiers .into_iter() @@ -50,7 +48,7 @@ async fn quarantines_tests_regardless_of_upload() { QuarantineConfigResponse::All => test_ids, }; async { - Json(QuarantineConfig { + Json(GetQuarantineConfigResponse { is_disabled: false, quarantined_tests, }) diff --git a/cli-tests/src/upload.rs b/cli-tests/src/upload.rs index ef416ab4..3b8e9754 100644 --- a/cli-tests/src/upload.rs +++ b/cli-tests/src/upload.rs @@ -4,7 +4,7 @@ use crate::utils::{ generate_mock_bazel_bep, generate_mock_codeowners, generate_mock_git_repo, generate_mock_valid_junit_xmls, CARGO_RUN, }; -use api::{BundleUploadStatus, CreateRepoRequest, UpdateBundleUploadRequest}; +use api::message::{BundleUploadStatus, CreateRepoRequest, UpdateBundleUploadRequest}; use assert_cmd::Command; use assert_matches::assert_matches; use bundle::{BundleMeta, FileSetType}; diff --git a/cli/Cargo.toml b/cli/Cargo.toml index c0408e58..25316850 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -47,14 +47,7 @@ console = "0.15.8" serde_json = "1.0" [dev-dependencies] -axum = { version = "0.7.5", features = ["macros"] } -lazy_static = "1.5.0" -test_utils = { path = "../test_utils" } -tokio = { version = "*", default-features = false, features = [ - "rt-multi-thread", - "macros", - "test-util", -] } +test_utils = { version = "0.1.0", path = "../test_utils" } [build-dependencies] vergen = { version = "8.3.1", features = [ diff --git a/cli/src/context.rs b/cli/src/context.rs index 5366cf4d..0f3a3ec1 100644 --- a/cli/src/context.rs +++ b/cli/src/context.rs @@ -8,7 +8,7 @@ use std::{ time::{SystemTime, UNIX_EPOCH}, }; -use api::CreateBundleUploadResponse; +use api::message::CreateBundleUploadResponse; use bundle::{ parse_custom_tags, BundleMeta, BundleMetaBaseProps, BundleMetaDebugProps, BundleMetaJunitProps, FileSet, FileSetBuilder, QuarantineBulkTestStatus, META_VERSION, @@ -26,12 +26,12 @@ use tempfile::TempDir; use xcresult::XCResult; use crate::{ - api_client::ApiClient, context_quarantine::{gather_quarantine_context, FailedTestsExtractor, QuarantineContext}, print::print_bep_results, test_command::TestRunResult, upload_command::UploadArgs, }; +use api::client::ApiClient; pub struct PreTestContext { pub meta: BundleMeta, @@ -253,7 +253,7 @@ pub async fn gather_exit_code_and_quarantined_tests_context( } else { gather_quarantine_context( api_client, - &api::GetQuarantineBulkTestStatusRequest { + &api::message::GetQuarantineConfigRequest { repo: meta.base_props.repo.repo.clone(), org_url_slug: meta.base_props.org.clone(), test_identifiers: failed_tests_extractor.failed_tests().to_vec(), @@ -275,7 +275,7 @@ pub async fn gather_upload_id_context( api_client: &ApiClient, ) -> anyhow::Result { let upload = api_client - .create_bundle_upload_intent(&api::CreateBundleUploadRequest { + .create_bundle_upload(&api::message::CreateBundleUploadRequest { repo: meta.base_props.repo.repo.clone(), org_url_slug: meta.base_props.org.clone(), client_version: format!("trunk-analytics-cli {}", meta.base_props.cli_version), diff --git a/cli/src/context_quarantine.rs b/cli/src/context_quarantine.rs index 450cf888..0247df9f 100644 --- a/cli/src/context_quarantine.rs +++ b/cli/src/context_quarantine.rs @@ -8,7 +8,7 @@ use context::{ }; use quick_junit::TestCaseStatus; -use crate::api_client::ApiClient; +use api::client::ApiClient; #[derive(Debug, Default, Clone)] pub struct QuarantineContext { @@ -155,7 +155,7 @@ impl FailedTestsExtractor { pub async fn gather_quarantine_context( api_client: &ApiClient, - request: &api::GetQuarantineBulkTestStatusRequest, + request: &api::message::GetQuarantineConfigRequest, file_set_builder: &FileSetBuilder, failed_tests_extractor: Option, test_run_exit_code: Option, @@ -178,20 +178,19 @@ pub async fn gather_quarantine_context( }; } - let quarantine_config: api::QuarantineConfig = - if !failed_tests_extractor.failed_tests().is_empty() { - log::info!("Checking if failed tests can be quarantined"); - let result = api_client.get_quarantining_config(request).await; + let quarantine_config = if !failed_tests_extractor.failed_tests().is_empty() { + log::info!("Checking if failed tests can be quarantined"); + let result = api_client.get_quarantining_config(request).await; - if let Err(ref err) = result { - log::error!("{}", err); - } + if let Err(ref err) = result { + log::error!("{}", err); + } - result.unwrap_or_default() - } else { - log::debug!("No failed tests to quarantine"); - api::QuarantineConfig::default() - }; + result.unwrap_or_default() + } else { + log::debug!("No failed tests to quarantine"); + api::message::GetQuarantineConfigResponse::default() + }; // if quarantining is not enabled, return exit code and empty quarantine status if quarantine_config.is_disabled { diff --git a/cli/src/lib.rs b/cli/src/lib.rs index 6fdc3b6a..2dc99d6f 100644 --- a/cli/src/lib.rs +++ b/cli/src/lib.rs @@ -1,4 +1,3 @@ -pub mod api_client; pub mod context; pub mod context_quarantine; pub mod print; diff --git a/cli/src/upload_command.rs b/cli/src/upload_command.rs index 274c62a9..048b0d37 100644 --- a/cli/src/upload_command.rs +++ b/cli/src/upload_command.rs @@ -1,11 +1,11 @@ -use api::BundleUploadStatus; +use api::client::ApiClient; +use api::message::BundleUploadStatus; use bundle::{BundleMeta, BundlerUtil}; use clap::{ArgAction, Args}; use constants::EXIT_SUCCESS; use context::bazel_bep::parser::BepParseResult; use crate::{ - api_client::ApiClient, context::{ gather_exit_code_and_quarantined_tests_context, gather_post_test_context, gather_pre_test_context, gather_upload_id_context, PreTestContext, @@ -200,7 +200,7 @@ async fn upload_bundle( exit_code: i32, ) -> anyhow::Result<()> { api_client - .create_trunk_repo(&api::CreateRepoRequest { + .create_repo(&api::message::CreateRepoRequest { repo: meta.base_props.repo.repo.clone(), org_url_slug: meta.base_props.org.clone(), remote_urls: vec![meta.base_props.repo.repo_url.clone()], @@ -218,7 +218,7 @@ async fn upload_bundle( if no_upload { if let Err(e) = api_client - .update_bundle_upload_status(&api::UpdateBundleUploadRequest { + .update_bundle_upload(&api::message::UpdateBundleUploadRequest { id: upload.id.clone(), upload_status: BundleUploadStatus::DryRun, }) @@ -235,7 +235,7 @@ async fn upload_bundle( .await?; if let Err(e) = api_client - .update_bundle_upload_status(&api::UpdateBundleUploadRequest { + .update_bundle_upload(&api::message::UpdateBundleUploadRequest { id: upload.id.clone(), upload_status: BundleUploadStatus::UploadComplete, }) diff --git a/test_utils/src/mock_server.rs b/test_utils/src/mock_server.rs index 3d5d6f4f..907f71b1 100644 --- a/test_utils/src/mock_server.rs +++ b/test_utils/src/mock_server.rs @@ -5,9 +5,10 @@ use std::{ sync::{Arc, Mutex}, }; -use api::{ - CreateBundleUploadRequest, CreateBundleUploadResponse, CreateRepoRequest, - GetQuarantineBulkTestStatusRequest, QuarantineConfig, UpdateBundleUploadRequest, +use api::message::{ + CreateBundleUploadRequest, CreateBundleUploadResponse, CreateRepoRequest, CreateRepoResponse, + GetQuarantineConfigRequest, GetQuarantineConfigResponse, UpdateBundleUploadRequest, + UpdateBundleUploadResponse, }; use axum::{ body::Bytes, @@ -26,7 +27,7 @@ pub enum RequestPayload { CreateRepo(CreateRepoRequest), CreateBundleUpload(CreateBundleUploadRequest), UpdateBundleUpload(UpdateBundleUploadRequest), - GetQuarantineBulkTestStatus(GetQuarantineBulkTestStatusRequest), + GetQuarantineBulkTestStatus(GetQuarantineConfigRequest), S3Upload(PathBuf), } @@ -151,13 +152,13 @@ pub type SharedMockServerState = Arc; async fn repo_create_handler( State(state): State, Json(create_repo_request): Json, -) -> Response { +) -> Json { state .requests .lock() .unwrap() .push(RequestPayload::CreateRepo(create_repo_request)); - Response::new(String::from("OK")) + Json(CreateRepoResponse {}) } #[axum::debug_handler] @@ -185,7 +186,7 @@ pub async fn create_bundle_handler( pub async fn update_bundle_handler( State(state): State, Json(update_bundle_upload_request): Json, -) -> Response { +) -> Json { state .requests .lock() @@ -193,14 +194,14 @@ pub async fn update_bundle_handler( .push(RequestPayload::UpdateBundleUpload( update_bundle_upload_request, )); - Response::new(String::from("OK")) + Json(UpdateBundleUploadResponse {}) } #[axum::debug_handler] pub async fn get_quarantining_config_handler( State(state): State, - Json(get_quarantine_bulk_test_status_request): Json, -) -> Json { + Json(get_quarantine_bulk_test_status_request): Json, +) -> Json { state .requests .lock() @@ -208,7 +209,7 @@ pub async fn get_quarantining_config_handler( .push(RequestPayload::GetQuarantineBulkTestStatus( get_quarantine_bulk_test_status_request, )); - Json(QuarantineConfig { + Json(GetQuarantineConfigResponse { is_disabled: false, quarantined_tests: Vec::new(), })