Skip to content

Commit

Permalink
Fix the POST ratings analysis endpoint (#142)
Browse files Browse the repository at this point in the history
Fixes the endpoint creating new rating analysis.

Signed-off-by: Rémy Greinhofer <[email protected]>
  • Loading branch information
rgreinho authored Sep 3, 2024
1 parent bb9f110 commit 12837d9
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
3 changes: 1 addition & 2 deletions entity/src/wrappers/bna_pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ pub struct BNAPipelinePost {
pub sqs_message: Option<Json>,
pub start_time: TimeDateTimeWithTimeZone,
pub state_machine_id: Uuid,
pub status: String,
pub step: Option<String>,
pub torn_down: Option<bool>,
}
Expand All @@ -33,7 +32,7 @@ impl IntoActiveModel<bna_pipeline::ActiveModel> for BNAPipelinePost {
sqs_message: ActiveValue::Set(self.sqs_message),
start_time: ActiveValue::Set(self.start_time),
state_machine_id: ActiveValue::Set(self.state_machine_id),
status: ActiveValue::Set(self.status),
status: ActiveValue::Set("Pending".to_string()),
step: ActiveValue::Set(self.step),
torn_down: ActiveValue::Set(self.torn_down),
}
Expand Down
47 changes: 47 additions & 0 deletions lambdas/src/ratings/post-ratings-analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,50 @@ async fn main() -> Result<(), Error> {
e
})
}

#[cfg(test)]
mod tests {

use super::*;
use aws_lambda_events::http;
use lambda_http::RequestExt;

#[tokio::test]
async fn test_handler_all() {
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_request_context(lambda_http::request::RequestContext::ApiGatewayV2(
lambda_http::aws_lambda_events::apigw::ApiGatewayV2httpRequestContext::default(),
));
let r = function_handler(event).await;
let _var_name = dbg!(r);
}
}

0 comments on commit 12837d9

Please sign in to comment.