Skip to content

Commit 83fe53a

Browse files
authored
Merge pull request #23 from sine-fdn/hoc-schema
test: schema json's availability
2 parents 5659049 + 75347fa commit 83fe53a

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

demo-api/src/main.rs

+25-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,24 @@ 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 endpoints = vec![
1350+
("/shipment-footprint.json", schema_for!(ShipmentFootprint)),
1351+
("/toc.json", schema_for!(Toc)),
1352+
("/hoc.json", schema_for!(Hoc)),
1353+
];
1354+
1355+
let client = &Client::tracked(create_server(TEST_KEYPAIR.clone())).unwrap();
1356+
1357+
for (endpoint, schema) in endpoints {
1358+
let schema_resp = client.get(endpoint).dispatch();
1359+
1360+
assert_eq!(schema_resp.status(), rocket::http::Status::Ok);
1361+
1362+
let fetched_schema = schema_resp.into_json::<RootSchema>();
1363+
1364+
assert_eq!(fetched_schema.unwrap(), schema);
1365+
}
1366+
}

0 commit comments

Comments
 (0)