Skip to content

Commit 75347fa

Browse files
refactor: improve test readability @zeitgeist
1 parent 7d04f57 commit 75347fa

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

demo-api/src/main.rs

+8-14
Original file line numberDiff line numberDiff line change
@@ -1346,27 +1346,21 @@ fn get_tad_with_limit_and_filter_test() {
13461346

13471347
#[test]
13481348
fn schema_jsons_test() {
1349+
let endpoints = vec![
1350+
("/shipment-footprint.json", schema_for!(ShipmentFootprint)),
1351+
("/toc.json", schema_for!(Toc)),
1352+
("/hoc.json", schema_for!(Hoc)),
1353+
];
1354+
13491355
let client = &Client::tracked(create_server(TEST_KEYPAIR.clone())).unwrap();
13501356

1351-
fn test_schema(client: &Client, schema_url: &str, schema: RootSchema) {
1352-
let schema_resp = client.get(schema_url).dispatch();
1357+
for (endpoint, schema) in endpoints {
1358+
let schema_resp = client.get(endpoint).dispatch();
13531359

13541360
assert_eq!(schema_resp.status(), rocket::http::Status::Ok);
13551361

13561362
let fetched_schema = schema_resp.into_json::<RootSchema>();
13571363

13581364
assert_eq!(fetched_schema.unwrap(), schema);
13591365
}
1360-
1361-
let ship_foot_schema_url = "/shipment-footprint.json";
1362-
let ship_foot_schema = schema_for!(ShipmentFootprint);
1363-
test_schema(client, ship_foot_schema_url, ship_foot_schema);
1364-
1365-
let toc_schema_url: &str = "/toc.json";
1366-
let toc_schema = schema_for!(Toc);
1367-
test_schema(client, toc_schema_url, toc_schema);
1368-
1369-
let hoc_schema_url = "/hoc.json";
1370-
let hoc_schema = schema_for!(Hoc);
1371-
test_schema(client, hoc_schema_url, hoc_schema);
13721366
}

0 commit comments

Comments
 (0)