Skip to content

Commit 7d04f57

Browse files
test: schema json's availability
1 parent 72b375f commit 7d04f57

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

demo-api/src/main.rs

+31-1
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,10 @@ fn create_server(key_pair: KeyPair) -> rocket::Rocket<rocket::Build> {
659659
.mount("/", routes![index])
660660
.mount("/", routes![get_list, get_pcf_unauth, post_event_fallback])
661661
.mount("/", routes![openid_configuration, jwks])
662-
.mount("/", routes![shipment_footprint_schema, toc_schema, hoc_schema])
662+
.mount(
663+
"/",
664+
routes![shipment_footprint_schema, toc_schema, hoc_schema],
665+
)
663666
.mount("/auth", routes![oauth2_create_token])
664667
.mount(
665668
"/swagger-ui/",
@@ -1340,3 +1343,30 @@ fn get_tad_with_limit_and_filter_test() {
13401343
resp.into_string().unwrap()
13411344
);
13421345
}
1346+
1347+
#[test]
1348+
fn schema_jsons_test() {
1349+
let client = &Client::tracked(create_server(TEST_KEYPAIR.clone())).unwrap();
1350+
1351+
fn test_schema(client: &Client, schema_url: &str, schema: RootSchema) {
1352+
let schema_resp = client.get(schema_url).dispatch();
1353+
1354+
assert_eq!(schema_resp.status(), rocket::http::Status::Ok);
1355+
1356+
let fetched_schema = schema_resp.into_json::<RootSchema>();
1357+
1358+
assert_eq!(fetched_schema.unwrap(), schema);
1359+
}
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);
1372+
}

0 commit comments

Comments
 (0)