Skip to content

Commit

Permalink
Fix the PATCH ratings/analysis endpoint
Browse files Browse the repository at this point in the history
Fixes the PATCH ratings/analysis endpoint.

Signed-off-by: Rémy Greinhofer <[email protected]>
  • Loading branch information
rgreinho committed Sep 3, 2024
1 parent 12837d9 commit 4106b3a
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 3 deletions.
2 changes: 0 additions & 2 deletions entity/src/wrappers/bna_pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,8 @@ pub struct BNAPipelinePatch {
pub end_time: Option<Option<TimeDateTimeWithTimeZone>>,
pub fargate_price_id: Option<Option<i32>>,
pub fargate_task_arn: Option<Option<String>>,
pub neon_branch_id: Option<Option<String>>,
pub result_posted: Option<Option<bool>>,
pub s3_bucket: Option<Option<String>>,
pub scheduled_trigger_id: Option<Option<Uuid>>,
pub sqs_message: Option<Option<Json>>,
pub start_time: Option<Option<TimeDateTimeWithTimeZone>>,
pub status: Option<String>,
Expand Down
54 changes: 53 additions & 1 deletion lambdas/src/ratings/patch-ratings-analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async fn function_handler(event: Request) -> Result<Response<Body>, Error> {

pub fn prepare_active_model(event: &Request) -> Result<ActiveModel, APIErrors> {
// Retrieve the ID of the entry to update.
let parameter = "id";
let parameter = "analysis_id";
let id = event
.path_parameter::<Uuid>(parameter)
.ok_or(missing_parameter(event, parameter))?
Expand Down Expand Up @@ -65,3 +65,55 @@ async fn main() -> Result<(), Error> {
e
})
}

#[cfg(test)]
mod tests {

use super::*;
use aws_lambda_events::http;
use lambda_http::RequestExt;
use std::collections::HashMap;

#[test]
fn test_prepare_active_model() {
let event = http::Request::builder()
.header(http::header::CONTENT_TYPE, "application/json")
.body(Body::Text(
r#"{
"cost": null,
"end_time": null,
"fargate_price_id": null,
"fargate_task_arn": null,
"result_posted": null,
"s3_bucket": null,
"sqs_message": null,
"start_time": [
2024,
247,
13,
7,
29,
922293000,
0,
0,
0
],
"state_machine_id": "fc009967-c4d0-416b-baee-93708ac80cbc",
"status": null,
"step": "Analysis",
"torn_down": null
}"#
.to_string(),
))
.expect("failed to build request")
.with_path_parameters(HashMap::from([(
"analysis_id".to_string(),
"fc009967-c4d0-416b-baee-93708ac80cbc".to_string(), // Santa Monica, CA
)]))
.with_request_context(lambda_http::request::RequestContext::ApiGatewayV2(
lambda_http::aws_lambda_events::apigw::ApiGatewayV2httpRequestContext::default(),
));
let r = prepare_active_model(&event);
assert!(r.is_ok());
}
}

0 comments on commit 4106b3a

Please sign in to comment.