Skip to content

Commit

Permalink
chore: update tests after new test data
Browse files Browse the repository at this point in the history
  • Loading branch information
zeitgeist committed Apr 16, 2024
1 parent 5966cdb commit bda6c08
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 28 deletions.
33 changes: 6 additions & 27 deletions endpoint/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ fn get_list_with_filter_eq_test() {

assert_eq!(rocket::http::Status::Ok, resp.status());
let json: PfListingResponseInner = resp.into_json().unwrap();
assert_eq!(json.data.len(), 5);
assert_eq!(json.data.len(), 1);
}

#[test]
Expand All @@ -677,7 +677,7 @@ fn get_list_with_filter_lt_test() {

let bearer_token = format!("Bearer {jwt}");

let get_list_with_limit_uri = "/2/footprints?$filter=updated+lt+'2023-01-01T00:00:00.000Z'";
let get_list_with_limit_uri = "/2/footprints?$filter=updated+lt+'2023-06-27T13:00:00.000Z'";

let resp = client
.get(get_list_with_limit_uri)
Expand All @@ -687,7 +687,7 @@ fn get_list_with_filter_lt_test() {

assert_eq!(rocket::http::Status::Ok, resp.status());
let json: PfListingResponseInner = resp.into_json().unwrap();
assert_eq!(json.data.len(), 3);
assert_eq!(json.data.len(), 1);
}

#[test]
Expand All @@ -703,7 +703,7 @@ fn get_list_with_filter_eq_and_lt_test() {
let jwt = auth::encode_token(&token, key_pair).ok().unwrap();
let bearer_token = format!("Bearer {jwt}");

let get_list_with_limit_uri = "/2/footprints?$filter=(pcf/geographyCountry+eq+'FR')+and+(updated+lt+'2023-01-01T00:00:00.000Z')";
let get_list_with_limit_uri = "/2/footprints?$filter=(pcf/geographyCountry+eq+'FR')+and+(updated+lt+'2023-06-27T12:12:04.000Z')";

let resp = client
.get(get_list_with_limit_uri)
Expand Down Expand Up @@ -743,7 +743,7 @@ fn get_list_with_filter_any_test() {

assert_eq!(rocket::http::Status::Ok, resp.status());
let json: PfListingResponseInner = resp.into_json().unwrap();
assert_eq!(json.data.len(), 8);
assert_eq!(json.data.len(), 1);

let get_list_with_limit_uri =
"/2/footprints?$filter=productIds/any(productId:(productId+eq+'urn:gtin:12345'))";
Expand Down Expand Up @@ -774,7 +774,6 @@ fn get_list_with_limit_test() {

let get_list_with_limit_uri = "/2/footprints?limit=3";
let expected_next_link1 = "/2/footprints?offset=3&limit=3";
let expected_next_link2 = "/2/footprints?offset=6&limit=3";

{
let resp = client
Expand All @@ -799,34 +798,14 @@ fn get_list_with_limit_test() {
{
let resp = client
.get(expected_next_link1)
.header(rocket::http::Header::new(
"Authorization",
bearer_token.clone(),
))
.header(rocket::http::Header::new("Host", EXAMPLE_HOST))
.dispatch();

assert_eq!(rocket::http::Status::Ok, resp.status());
let link_header = resp.headers().get("link").next().unwrap().to_string();
assert_eq!(
link_header,
format!("<https://api.pathfinder.sine.dev{expected_next_link2}>; rel=\"next\"")
);
let json: PfListingResponseInner = resp.into_json().unwrap();
assert_eq!(json.data.len(), 3);
}

{
let resp = client
.get(expected_next_link2)
.header(rocket::http::Header::new("Authorization", bearer_token))
.header(rocket::http::Header::new("Host", EXAMPLE_HOST))
.dispatch();

assert_eq!(rocket::http::Status::Ok, resp.status());
assert_eq!(resp.headers().get("link").next(), None);
let json: PfListingResponseInner = resp.into_json().unwrap();
assert_eq!(json.data.len(), 2);
assert_eq!(json.data.len(), 1);
}
}

Expand Down
2 changes: 1 addition & 1 deletion endpoint/src/sample_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ lazy_static!(
boundary_processes_description: String::from("1) Material acquisition and preprocessing, including growth of trees 2) Production: fuel consumption, electricity consumption, water consumption, process-generated direct emissions 3) Distribution and storage: transportation of the finished product from manufacturing site to storage site"),
reference_period_start: Utc.ymd(2021, 1, 1).and_hms(00, 00, 00),
reference_period_end: Utc.ymd(2022, 1, 1).and_hms(00, 00, 00),
geographic_scope: Some(GeographicScope::Subdivision { geography_country_subdivision: String::from("FR-89").into() }),
geographic_scope: Some(GeographicScope::Country { geography_country: ISO3166CC("FR".into()) }),
secondary_emission_factor_sources: Some(EmissionFactorDSSet(vec![EmissionFactorDS {
name: String::from("Gabi").into(),
version: String::from("2022").into(),
Expand Down

0 comments on commit bda6c08

Please sign in to comment.