Skip to content

Commit

Permalink
fixes and added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
worldofjoni committed Jun 19, 2024
1 parent def9335 commit 43112b3
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 22 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions backend/src/layer/data/database/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,14 @@ mod test {
approved: false,
upload_date: Local::now().date_naive(),
report_count: 0,
meal_id: Uuid::default(),
meal_id: Uuid::parse_str("f7337122-b018-48ad-b420-6202dc3cb4ff").unwrap(),
},
meal_name: "Happy Meal".into(),
other_image_urls: vec!["https://picsum.photos/500/300".into()],
meal_name: "Geflügel - Cevapcici, Ajvar, Djuvec Reis".into(),
other_image_urls: vec![
"http://localhost/image/ea8cce48-a3c7-4f8e-a222-5f3891c13804.jpg".into(),
"http://localhost/image/1aa73d5d-1701-4975-aa3c-1422a8bc10e8.jpg".into(),
"http://localhost/image/76b904fe-d0f1-4122-8832-d0e21acab86d.jpg".into(),
],
}
}

Expand Down
2 changes: 1 addition & 1 deletion backend/src/layer/data/database/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ mod tests {
upvotes: 0,
upload_date: Local::now().date_naive(),
report_count: 0,
meal_id: Uuid::default(),
meal_id: Uuid::parse_str("f7337122-b018-48ad-b420-6202dc3cb4ff").unwrap(),
};
let image2 = Image {
id: Uuid::parse_str("76b904fe-d0f1-4122-8832-d0e21acab86d").unwrap(),
Expand Down
30 changes: 23 additions & 7 deletions backend/src/layer/data/mail/mail_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,10 @@ mod test {
report.contains(info.report_count.to_string().as_str()),
"the template must contain all of the information from the report info"
);
// assert!(
// report.contains(info.image_got_hidden.to_string().as_str()),
// "the template must contain all of the information from the report info"
// );
assert!(
report.contains(info.image_got_hidden.to_string().as_str()),
"the template must contain all of the information from the report info"
);
assert!(
report.contains(info.positive_rating_count.to_string().as_str()),
"the template must contain all of the information from the report info"
Expand All @@ -210,6 +210,22 @@ mod test {
report.contains(info.image_age.to_string().as_str()),
"the template must contain all of the information from the report info"
);
assert!(
report.contains(info.meal_id.to_string().as_str()),
"the template must contain all of the information from the report info"
);
assert!(
report.contains(info.meal_name.as_str()),
"the template must contain all of the information from the report info"
);
assert!(
report.contains(info.other_image_urls[0].as_str()),
"the template must contain all of the information from the report info"
);
assert!(
report.contains(info.report_date.to_string().as_str()),
"the template must contain all of the information from the report info"
);
assert!(
report.contains(REPORT_CSS), "Report css must be included. maybe auto-formatting destroyed the braces in template.html?"
);
Expand Down Expand Up @@ -247,16 +263,16 @@ mod test {
ImageReportInfo {
reason: crate::util::ReportReason::Advert,
image_got_hidden: true,
image_id: Uuid::default(),
image_id: Uuid::from_u128(9_789_789),
image_url: String::from("https://picsum.photos/500/330"),
report_count: 1,
positive_rating_count: 10,
negative_rating_count: 20,
image_rank: 1.0,
report_barrier: 1,
client_id: Uuid::default(),
client_id: Uuid::from_u128(123),
image_age: 1,
meal_id: Uuid::default(),
meal_id: Uuid::from_u128(567),
meal_name: "Happy Meal".into(),
report_date: Local::now().date_naive(),
other_image_urls: vec![
Expand Down
Loading

0 comments on commit 43112b3

Please sign in to comment.