Skip to content

Commit bed9099

Browse files
authored
[api] Add listQuarantinedTests support (#489)
Add support for invoking this endpoint. It will be used in a follow-up PR.
1 parent e0f8450 commit bed9099

File tree

2 files changed

+88
-0
lines changed

2 files changed

+88
-0
lines changed

api/src/client.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,41 @@ impl ApiClient {
184184
.await
185185
}
186186

187+
pub async fn list_quarantined_tests(
188+
&self,
189+
request: &message::ListQuarantinedTestsRequest,
190+
) -> anyhow::Result<message::ListQuarantinedTestsResponse> {
191+
CallApi {
192+
action: || async {
193+
let response = self
194+
.trunk_api_client
195+
.post(format!("{}{}/flaky-tests/list-quarantined-tests", self.api_host, self.version_path_prefix))
196+
.json(&request)
197+
.send()
198+
.await?;
199+
200+
let response = status_code_help(
201+
response,
202+
CheckUnauthorized::Check,
203+
CheckNotFound::DoNotCheck,
204+
|_| String::from("Failed to list quarantined tests."),
205+
&self.api_host,
206+
&self.org_url_slug,
207+
)?;
208+
209+
self.deserialize_response::<message::ListQuarantinedTestsResponse>(response).await
210+
},
211+
log_progress_message: |time_elapsed, _| {
212+
format!("Listing quarantined tests from Trunk services is taking longer than expected. It has taken {} seconds so far.", time_elapsed.as_secs())
213+
},
214+
report_slow_progress_message: |time_elapsed| {
215+
format!("Listing quarantined tests from Trunk services is taking longer than {} seconds", time_elapsed.as_secs())
216+
},
217+
}
218+
.call_api()
219+
.await
220+
}
221+
187222
pub async fn put_bundle_to_s3<U: AsRef<str>, B: AsRef<Path>>(
188223
&self,
189224
url: U,

api/src/message.rs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,56 @@ pub struct CreateBundleUploadIntentResponse {
6363
pub struct TelemetryUploadMetricsRequest {
6464
pub upload_metrics: proto::upload_metrics::trunk::UploadMetrics,
6565
}
66+
67+
#[derive(Debug, Serialize, Clone, Deserialize, PartialEq)]
68+
pub struct PageQuery {
69+
#[serde(rename = "pageSize")]
70+
pub page_size: i32,
71+
#[serde(rename = "pageToken")]
72+
pub page_token: String,
73+
}
74+
75+
#[derive(Debug, Serialize, Clone, Deserialize, PartialEq)]
76+
pub struct Page {
77+
pub total_rows: i32,
78+
pub total_pages: i32,
79+
pub next_page_token: String,
80+
pub prev_page_token: String,
81+
pub last_page_token: String,
82+
pub page_index: i32,
83+
}
84+
85+
#[derive(Debug, Serialize, Clone, Deserialize, PartialEq)]
86+
pub struct ListQuarantinedTestsRequest {
87+
pub repo: RepoUrlParts,
88+
#[serde(rename = "orgUrlSlug")]
89+
pub org_url_slug: String,
90+
#[serde(rename = "pageQuery")]
91+
pub page_query: PageQuery,
92+
}
93+
94+
#[derive(Debug, Serialize, Clone, Deserialize, PartialEq)]
95+
pub enum QuarantineSetting {
96+
#[serde(rename = "ALWAYS_QUARANTINE")]
97+
AlwaysQuarantine,
98+
#[serde(rename = "AUTO_QUARANTINE")]
99+
AutoQuarantine,
100+
}
101+
102+
#[derive(Debug, Serialize, Clone, Deserialize, PartialEq)]
103+
pub struct QuarantinedTest {
104+
pub name: String,
105+
pub parent: Option<String>,
106+
pub file: Option<String>,
107+
#[serde(rename = "className")]
108+
pub class_name: Option<String>,
109+
pub status: String,
110+
pub quarantine_setting: QuarantineSetting,
111+
pub test_case_id: String,
112+
}
113+
114+
#[derive(Debug, Serialize, Clone, Deserialize, PartialEq)]
115+
pub struct ListQuarantinedTestsResponse {
116+
pub quarantined_tests: Vec<QuarantinedTest>,
117+
pub page: Page,
118+
}

0 commit comments

Comments
 (0)