Skip to content

Commit ff2d433

Browse files
authored
[api] Send variant information (#934)
We don't actually directly use this information because we send the ID directly, but it is a part of the request and we should send it.
1 parent 1cbbb03 commit ff2d433

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

api/src/urls.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use bundle::Test;
22
use context::repo::RepoUrlParts;
3-
use url::{form_urlencoded, ParseError, Url};
3+
use url::{ParseError, Url, form_urlencoded};
44

55
pub fn url_for_test_case(
66
public_api_address: &str,
@@ -46,6 +46,7 @@ fn test_url_generated() {
4646
timestamp_millis: None,
4747
is_quarantined: false,
4848
failure_message: None,
49+
variant: None,
4950
};
5051

5152
let actual = url_for_test_case(
@@ -56,11 +57,9 @@ fn test_url_generated() {
5657
);
5758

5859
assert_eq!(
59-
actual,
60-
Ok(
61-
String::from(
62-
"https://app.trunk-staging.io/bad-app-org/flaky-tests/test/c33a7f64-8f3e-5db9-b37b-2ea870d2441b?repo=bad-app%2Fios-app"
63-
)
64-
),
65-
);
60+
actual,
61+
Ok(String::from(
62+
"https://app.trunk-staging.io/bad-app-org/flaky-tests/test/c33a7f64-8f3e-5db9-b37b-2ea870d2441b?repo=bad-app%2Fios-app"
63+
)),
64+
);
6665
}

bundle/src/types.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ pub struct Test {
2424
pub timestamp_millis: Option<i64>,
2525
pub is_quarantined: bool,
2626
pub failure_message: Option<String>,
27+
pub variant: Option<String>,
2728
}
2829

2930
impl Test {
30-
pub fn new<T: AsRef<str>>(
31+
// trunk-ignore(clippy/too_many_arguments)
32+
pub fn new<T: AsRef<str> + ToString>(
3133
id: Option<T>,
3234
name: String,
3335
parent_name: String,
@@ -47,6 +49,7 @@ impl Test {
4749
timestamp_millis,
4850
is_quarantined: false,
4951
failure_message: None,
52+
variant: Some(variant.to_string()),
5053
};
5154

5255
if let Some(id) = id {
@@ -193,6 +196,7 @@ mod tests {
193196
timestamp_millis: Some(0),
194197
is_quarantined: false,
195198
failure_message: None,
199+
variant: Some(String::new()),
196200
};
197201
assert_eq!(result.name, name);
198202
assert_eq!(result.parent_name, parent_name);

cli/src/context_quarantine.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use context::{
1515
BindingsReport, BindingsTestCase, BindingsTestCaseStatusStatus, BindingsTestSuite,
1616
},
1717
junit_path::TestRunnerReportStatus,
18-
parser::{bin_parse, JunitParser},
18+
parser::{JunitParser, bin_parse},
1919
},
2020
repo::RepoUrlParts,
2121
};
@@ -71,7 +71,7 @@ impl QuarantineContext {
7171
}
7272
}
7373

74-
fn convert_case_to_test<T: AsRef<str>>(
74+
fn convert_case_to_test<T: AsRef<str> + ToString>(
7575
repo: &RepoUrlParts,
7676
org_slug: T,
7777
parent_name: String,
@@ -104,12 +104,12 @@ fn convert_case_to_test<T: AsRef<str>>(
104104
timestamp_millis,
105105
is_quarantined: case.is_quarantined(),
106106
failure_message,
107+
variant: Some(variant.to_string()),
107108
};
108109
if let Some(id) = case.extra().get("id") {
109110
if id.is_empty() {
110111
test.set_id(org_slug, repo, variant);
111112
} else {
112-
// trunk-ignore(clippy/assigning_clones)
113113
test.id = id.clone();
114114
}
115115
} else {

0 commit comments

Comments
 (0)