From 3fccfa2cd0daa9fd80af629ed7a86a58cec18a45 Mon Sep 17 00:00:00 2001 From: Jon Seager Date: Sat, 7 Feb 2026 09:48:26 +0000 Subject: [PATCH] test: update test struct initializers for created_at field Add `created_at: None` to all New*/Update* struct constructions in integration tests so they compile with the new optional field. --- tests/server/backup.rs | 9 +++++++++ tests/server/bags_api.rs | 7 +++++++ tests/server/brews_api.rs | 10 ++++++++++ tests/server/cafes_api.rs | 8 ++++++++ tests/server/cups_api.rs | 5 +++++ tests/server/datastar.rs | 8 ++++++++ tests/server/gear_api.rs | 2 ++ tests/server/helpers.rs | 5 +++++ tests/server/roasters_api.rs | 12 ++++++++++++ tests/server/roasts_api.rs | 9 +++++++++ tests/server/timeline.rs | 8 ++++++++ 11 files changed, 83 insertions(+) diff --git a/tests/server/backup.rs b/tests/server/backup.rs index 0998d07..6ae1197 100644 --- a/tests/server/backup.rs +++ b/tests/server/backup.rs @@ -153,6 +153,7 @@ async fn populate_test_data(db: &TestDb) -> (Roaster, Roast, Bag, Gear, Gear, Ge country: "UK".to_string(), city: Some("London".to_string()), homepage: Some("https://shop.squaremilecoffee.com".to_string()), + created_at: None, }) .await .expect("failed to create roaster"); @@ -172,6 +173,7 @@ async fn populate_test_data(db: &TestDb) -> (Roaster, Roast, Bag, Gear, Gear, Ge "Caramel".to_string(), ], process: "Natural".to_string(), + created_at: None, }) .await .expect("failed to create roast"); @@ -183,6 +185,7 @@ async fn populate_test_data(db: &TestDb) -> (Roaster, Roast, Bag, Gear, Gear, Ge roast_id: roast.id, roast_date: Some(chrono::NaiveDate::from_ymd_opt(2025, 1, 15).unwrap()), amount: 250.0, + created_at: None, }) .await .expect("failed to create bag"); @@ -194,6 +197,7 @@ async fn populate_test_data(db: &TestDb) -> (Roaster, Roast, Bag, Gear, Gear, Ge category: GearCategory::Grinder, make: "Comandante".to_string(), model: "C40 MK4".to_string(), + created_at: None, }) .await .expect("failed to create grinder"); @@ -204,6 +208,7 @@ async fn populate_test_data(db: &TestDb) -> (Roaster, Roast, Bag, Gear, Gear, Ge category: GearCategory::Brewer, make: "Hario".to_string(), model: "V60 02".to_string(), + created_at: None, }) .await .expect("failed to create brewer"); @@ -214,6 +219,7 @@ async fn populate_test_data(db: &TestDb) -> (Roaster, Roast, Bag, Gear, Gear, Ge category: GearCategory::FilterPaper, make: "Hario".to_string(), model: "V60 Tabbed 02".to_string(), + created_at: None, }) .await .expect("failed to create filter paper"); @@ -231,6 +237,7 @@ async fn populate_test_data(db: &TestDb) -> (Roaster, Roast, Bag, Gear, Gear, Ge water_volume: 250, water_temp: 93.5, quick_notes: Vec::new(), + created_at: None, }) .await .expect("failed to create brew"); @@ -257,6 +264,7 @@ async fn populate_test_data(db: &TestDb) -> (Roaster, Roast, Bag, Gear, Gear, Ge latitude: 51.5246, longitude: -0.1098, website: Some("https://prufrockcoffee.com".to_string()), + created_at: None, }) .await .expect("failed to create cafe"); @@ -435,6 +443,7 @@ async fn restore_to_non_empty_database_fails() { country: "UK".to_string(), city: None, homepage: None, + created_at: None, }) .await .expect("failed to create roaster"); diff --git a/tests/server/bags_api.rs b/tests/server/bags_api.rs index 73b676c..a28015b 100644 --- a/tests/server/bags_api.rs +++ b/tests/server/bags_api.rs @@ -16,6 +16,7 @@ async fn creating_a_bag_returns_a_201_for_valid_data() { roast_id: roast.id, roast_date: Some(NaiveDate::from_ymd_opt(2023, 1, 1).unwrap()), amount: 250.0, + created_at: None, }; // Act @@ -78,6 +79,7 @@ async fn listing_bags_returns_200_and_correct_data() { roast_id: roast.id, roast_date: None, amount: 500.0, + created_at: None, }; client @@ -116,6 +118,7 @@ async fn getting_a_bag_returns_200_for_valid_id() { roast_id: roast.id, roast_date: None, amount: 250.0, + created_at: None, }; let create_response = client @@ -156,6 +159,7 @@ async fn updating_a_bag_returns_200_and_updates_data() { roast_id: roast.id, roast_date: None, amount: 250.0, + created_at: None, }; let create_response = client @@ -175,6 +179,7 @@ async fn updating_a_bag_returns_200_and_updates_data() { remaining: Some(100.0), closed: Some(true), finished_at: Some(NaiveDate::from_ymd_opt(2023, 2, 1).unwrap()), + created_at: None, }; // Act @@ -209,6 +214,7 @@ async fn deleting_a_bag_returns_204() { roast_id: roast.id, roast_date: None, amount: 250.0, + created_at: None, }; let create_response = client @@ -257,6 +263,7 @@ async fn closing_a_bag_automatically_sets_finished_at() { roast_id: roast.id, roast_date: None, amount: 250.0, + created_at: None, }; let create_response = client diff --git a/tests/server/brews_api.rs b/tests/server/brews_api.rs index 0bed962..4e07148 100644 --- a/tests/server/brews_api.rs +++ b/tests/server/brews_api.rs @@ -26,6 +26,7 @@ async fn creating_a_brew_returns_201_for_valid_data() { water_volume: 250, water_temp: 92.0, quick_notes: Vec::new(), + created_at: None, }; // Act @@ -73,6 +74,7 @@ async fn creating_a_brew_with_filter_paper_returns_201() { water_volume: 250, water_temp: 92.0, quick_notes: Vec::new(), + created_at: None, }; // Act @@ -112,6 +114,7 @@ async fn creating_a_brew_deducts_from_bag_remaining() { water_volume: 250, water_temp: 92.0, quick_notes: Vec::new(), + created_at: None, }; // Act @@ -155,6 +158,7 @@ async fn creating_a_brew_fails_if_insufficient_coffee_in_bag() { water_volume: 250, water_temp: 92.0, quick_notes: Vec::new(), + created_at: None, }; // Act @@ -222,6 +226,7 @@ async fn listing_brews_returns_200_and_enriched_data() { water_volume: 250, water_temp: 92.0, quick_notes: Vec::new(), + created_at: None, }; client @@ -276,6 +281,7 @@ async fn listing_brews_without_filter_paper_returns_none() { water_volume: 255, water_temp: 88.0, quick_notes: Vec::new(), + created_at: None, }; client @@ -325,6 +331,7 @@ async fn listing_brews_with_bag_filter_returns_filtered_results() { water_volume: 250, water_temp: 92.0, quick_notes: Vec::new(), + created_at: None, }; client @@ -346,6 +353,7 @@ async fn listing_brews_with_bag_filter_returns_filtered_results() { water_volume: 255, water_temp: 88.0, quick_notes: Vec::new(), + created_at: None, }; client @@ -392,6 +400,7 @@ async fn getting_a_brew_returns_200_for_valid_id() { water_volume: 250, water_temp: 92.0, quick_notes: Vec::new(), + created_at: None, }; let create_response = client @@ -442,6 +451,7 @@ async fn deleting_a_brew_returns_204() { water_volume: 250, water_temp: 92.0, quick_notes: Vec::new(), + created_at: None, }; let create_response = client diff --git a/tests/server/cafes_api.rs b/tests/server/cafes_api.rs index 8ce5d24..d094b70 100644 --- a/tests/server/cafes_api.rs +++ b/tests/server/cafes_api.rs @@ -22,6 +22,7 @@ async fn creating_a_cafe_returns_a_201_for_valid_data() { latitude: 37.7749, longitude: -122.4194, website: Some("https://bluebottlecoffee.com".to_string()), + created_at: None, }; let response = client @@ -58,6 +59,7 @@ async fn creating_a_cafe_persists_the_data() { latitude: 48.8566, longitude: 2.3522, website: None, + created_at: None, }; let response = client @@ -93,6 +95,7 @@ async fn creating_a_cafe_requires_authentication() { latitude: 51.5074, longitude: -0.1278, website: None, + created_at: None, }; let response = client @@ -117,6 +120,7 @@ async fn listing_cafes_returns_a_200_with_multiple_cafes() { latitude: 51.5074, longitude: -0.1278, website: None, + created_at: None, }; let cafe2 = NewCafe { @@ -126,6 +130,7 @@ async fn listing_cafes_returns_a_200_with_multiple_cafes() { latitude: 52.52, longitude: 13.405, website: None, + created_at: None, }; client @@ -188,6 +193,7 @@ async fn updating_a_cafe_returns_a_200_for_valid_data() { latitude: None, longitude: None, website: Some("https://updated.com".to_string()), + created_at: None, }; let response = client @@ -219,6 +225,7 @@ async fn updating_a_cafe_with_no_changes_returns_a_400() { latitude: None, longitude: None, website: None, + created_at: None, }; let response = client @@ -244,6 +251,7 @@ async fn updating_a_nonexistent_cafe_returns_a_404() { latitude: None, longitude: None, website: None, + created_at: None, }; let response = client diff --git a/tests/server/cups_api.rs b/tests/server/cups_api.rs index 6bc45cb..3e0b3e6 100644 --- a/tests/server/cups_api.rs +++ b/tests/server/cups_api.rs @@ -23,6 +23,7 @@ async fn creating_a_cup_returns_a_201_for_valid_data() { let new_cup = NewCup { roast_id: roast.id, cafe_id: cafe.id, + created_at: None, }; let response = client @@ -48,6 +49,7 @@ async fn creating_a_cup_requires_authentication() { let new_cup = NewCup { roast_id: RoastId::new(1), cafe_id: CafeId::new(1), + created_at: None, }; let response = client @@ -72,6 +74,7 @@ async fn listing_cups_returns_a_200_with_enriched_data() { let new_cup = NewCup { roast_id: roast.id, cafe_id: cafe.id, + created_at: None, }; client @@ -109,6 +112,7 @@ async fn getting_a_cup_returns_a_200_with_details() { let new_cup = NewCup { roast_id: roast.id, cafe_id: cafe.id, + created_at: None, }; let create_response = client @@ -150,6 +154,7 @@ async fn deleting_a_cup_returns_a_204_for_valid_id() { let new_cup = NewCup { roast_id: roast.id, cafe_id: cafe.id, + created_at: None, }; let create_response = client diff --git a/tests/server/datastar.rs b/tests/server/datastar.rs index b9b587c..3af3ad9 100644 --- a/tests/server/datastar.rs +++ b/tests/server/datastar.rs @@ -108,6 +108,7 @@ async fn roasters_create_with_datastar_header_returns_fragment() { country: "UK".to_string(), city: None, homepage: None, + created_at: None, }; let response = client @@ -140,6 +141,7 @@ async fn roasters_create_without_datastar_header_returns_json() { country: "UK".to_string(), city: None, homepage: None, + created_at: None, }; let response = client @@ -193,6 +195,7 @@ async fn roasts_create_with_datastar_header_returns_fragment() { producer: "Test Farm".to_string(), tasting_notes: vec!["Blueberry".to_string()], process: "Washed".to_string(), + created_at: None, }; let response = client @@ -302,6 +305,7 @@ async fn bags_update_with_datastar_header_returns_fragment() { remaining: Some(100.0), closed: None, finished_at: None, + created_at: None, }; let response = client @@ -332,6 +336,7 @@ async fn bags_update_without_datastar_header_returns_json() { remaining: Some(100.0), closed: None, finished_at: None, + created_at: None, }; let response = client @@ -476,6 +481,7 @@ async fn gear_update_with_datastar_header_returns_fragment() { let update = brewlog::domain::gear::UpdateGear { make: Some("Updated Make".to_string()), model: None, + created_at: None, }; let response = client @@ -518,6 +524,7 @@ async fn gear_update_without_datastar_header_returns_json() { let update = brewlog::domain::gear::UpdateGear { make: Some("JSON Updated".to_string()), model: None, + created_at: None, }; let response = client @@ -552,6 +559,7 @@ async fn cafes_create_with_datastar_header_returns_fragment() { latitude: 51.5074, longitude: -0.1278, website: None, + created_at: None, }; let response = client diff --git a/tests/server/gear_api.rs b/tests/server/gear_api.rs index d32e714..dd0b91f 100644 --- a/tests/server/gear_api.rs +++ b/tests/server/gear_api.rs @@ -282,6 +282,7 @@ async fn updating_gear_returns_updated_data() { let update = UpdateGear { make: Some("Comandante".to_string()), model: Some("C40".to_string()), + created_at: None, }; let response = client @@ -310,6 +311,7 @@ async fn updating_gear_without_auth_returns_401() { let update = UpdateGear { make: Some("Updated".to_string()), model: None, + created_at: None, }; // Act diff --git a/tests/server/helpers.rs b/tests/server/helpers.rs index 8286535..42fa310 100644 --- a/tests/server/helpers.rs +++ b/tests/server/helpers.rs @@ -243,6 +243,7 @@ pub async fn create_default_roast( producer: "Coop".to_string(), tasting_notes: vec!["Blueberry".to_string()], process: "Washed".to_string(), + created_at: None, }, ) .await @@ -256,6 +257,7 @@ pub async fn create_roaster_with_name(app: &TestApp, name: &str) -> Roaster { country: "UK".to_string(), city: None, homepage: None, + created_at: None, }, ) .await @@ -272,6 +274,7 @@ pub async fn create_default_bag( roast_id, roast_date: Some(chrono::NaiveDate::from_ymd_opt(2023, 1, 1).unwrap()), amount: 250.0, + created_at: None, }, ) .await @@ -351,6 +354,7 @@ pub async fn create_default_gear( category: gear_category, make: make.to_string(), model: model.to_string(), + created_at: None, }, ) .await @@ -366,6 +370,7 @@ pub async fn create_default_cafe(app: &TestApp) -> Cafe { latitude: 37.7749, longitude: -122.4194, website: Some("https://bluebottlecoffee.com".to_string()), + created_at: None, }, ) .await diff --git a/tests/server/roasters_api.rs b/tests/server/roasters_api.rs index d4c776b..5561fdd 100644 --- a/tests/server/roasters_api.rs +++ b/tests/server/roasters_api.rs @@ -21,6 +21,7 @@ async fn creating_a_roaster_returns_a_201_for_valid_data() { country: "United Kingdom".to_string(), city: Some("London".to_string()), homepage: Some("https://example.com".to_string()), + created_at: None, }; // Act @@ -53,6 +54,7 @@ async fn creating_a_roaster_persists_the_data() { country: "France".to_string(), city: Some("Paris".to_string()), homepage: None, + created_at: None, }; // Act @@ -89,6 +91,7 @@ async fn getting_a_roaster_returns_a_200_for_valid_id() { country: "Germany".to_string(), city: Some("Berlin".to_string()), homepage: None, + created_at: None, }; let create_response = client @@ -131,6 +134,7 @@ async fn listing_roasters_returns_a_200_with_multiple_roasters() { country: "UK".to_string(), city: None, homepage: None, + created_at: None, }; let roaster2 = NewRoaster { @@ -138,6 +142,7 @@ async fn listing_roasters_returns_a_200_with_multiple_roasters() { country: "USA".to_string(), city: Some("New York".to_string()), homepage: None, + created_at: None, }; client @@ -181,6 +186,7 @@ async fn updating_a_roaster_returns_a_200_for_valid_data() { country: "UK".to_string(), city: Some("Manchester".to_string()), homepage: None, + created_at: None, }; let create_response = client @@ -201,6 +207,7 @@ async fn updating_a_roaster_returns_a_200_for_valid_data() { country: None, city: Some("Liverpool".to_string()), homepage: Some("https://updated.com".to_string()), + created_at: None, }; // Act @@ -236,6 +243,7 @@ async fn updating_a_roaster_with_no_changes_returns_a_400() { country: "UK".to_string(), city: None, homepage: None, + created_at: None, }; let create_response = client @@ -256,6 +264,7 @@ async fn updating_a_roaster_with_no_changes_returns_a_400() { country: None, city: None, homepage: None, + created_at: None, }; // Act @@ -282,6 +291,7 @@ async fn updating_a_nonexistent_roaster_returns_a_404() { country: None, city: None, homepage: None, + created_at: None, }; // Act @@ -308,6 +318,7 @@ async fn deleting_a_roaster_returns_a_204_for_valid_id() { country: "UK".to_string(), city: None, homepage: None, + created_at: None, }; let create_response = client @@ -356,6 +367,7 @@ async fn creating_a_roaster_with_empty_name_returns_a_201_after_normalization() country: "UK".to_string(), city: None, homepage: None, + created_at: None, }; // Act diff --git a/tests/server/roasts_api.rs b/tests/server/roasts_api.rs index 7243622..1c6bb66 100644 --- a/tests/server/roasts_api.rs +++ b/tests/server/roasts_api.rs @@ -29,6 +29,7 @@ async fn creating_a_roast_returns_a_201_for_valid_data() { "Citrus".to_string(), ], process: "Washed".to_string(), + created_at: None, }; // Act @@ -68,6 +69,7 @@ async fn creating_a_roast_persists_the_data() { producer: "Farm Co-op".to_string(), tasting_notes: vec!["Caramel".to_string(), "Nuts".to_string()], process: "Natural".to_string(), + created_at: None, }; // Act @@ -107,6 +109,7 @@ async fn creating_a_roast_with_nonexistent_roaster_returns_a_404() { producer: "Unknown Producer".to_string(), tasting_notes: vec!["Bitter".to_string()], process: "Unknown".to_string(), + created_at: None, }; // Act @@ -137,6 +140,7 @@ async fn getting_a_roast_returns_a_200_for_valid_id() { producer: "Estate".to_string(), tasting_notes: vec!["Blackcurrant".to_string()], process: "Washed".to_string(), + created_at: None, }; let create_response = client @@ -183,6 +187,7 @@ async fn listing_roasts_returns_a_200_with_multiple_roasts() { producer: "Farm A".to_string(), tasting_notes: vec!["Chocolate".to_string()], process: "Natural".to_string(), + created_at: None, }; let roast2 = NewRoast { @@ -193,6 +198,7 @@ async fn listing_roasts_returns_a_200_with_multiple_roasts() { producer: "Farm B".to_string(), tasting_notes: vec!["Caramel".to_string()], process: "Washed".to_string(), + created_at: None, }; client @@ -243,6 +249,7 @@ async fn listing_roasts_by_roaster_returns_a_200_with_filtered_list() { producer: "Farm A".to_string(), tasting_notes: vec!["Chocolate".to_string()], process: "Natural".to_string(), + created_at: None, }; let roast2 = NewRoast { @@ -253,6 +260,7 @@ async fn listing_roasts_by_roaster_returns_a_200_with_filtered_list() { producer: "Farm B".to_string(), tasting_notes: vec!["Caramel".to_string()], process: "Washed".to_string(), + created_at: None, }; client @@ -301,6 +309,7 @@ async fn deleting_a_roast_returns_a_204_for_valid_id() { producer: "Temporary Co-op".to_string(), tasting_notes: vec!["Fleeting".to_string()], process: "Washed".to_string(), + created_at: None, }; let create_response = client diff --git a/tests/server/timeline.rs b/tests/server/timeline.rs index 4c1a9db..ccda115 100644 --- a/tests/server/timeline.rs +++ b/tests/server/timeline.rs @@ -20,6 +20,7 @@ async fn create_roast(app: &crate::helpers::TestApp, roaster_id: RoasterId, name producer: "Chelbesa Cooperative".to_string(), tasting_notes: vec!["Blueberry".to_string(), "Jasmine".to_string()], process: "Washed".to_string(), + created_at: None, }; let response = client @@ -45,6 +46,7 @@ async fn seed_timeline_with_roasts( country: "UK".to_string(), city: Some("Bristol".to_string()), homepage: Some("https://example.com".to_string()), + created_at: None, }, ) .await; @@ -97,6 +99,7 @@ async fn creating_a_roaster_surfaces_on_the_timeline() { country: "UK".to_string(), city: Some("Bristol".to_string()), homepage: Some("https://example.com".to_string()), + created_at: None, }, ) .await; @@ -138,6 +141,7 @@ async fn creating_a_roast_surfaces_on_the_timeline() { country: "UK".to_string(), city: Some("Bristol".to_string()), homepage: Some("https://example.com".to_string()), + created_at: None, }, ) .await @@ -182,6 +186,7 @@ async fn creating_a_bag_surfaces_on_the_timeline() { country: "UK".to_string(), city: Some("Bristol".to_string()), homepage: Some("https://example.com".to_string()), + created_at: None, }, ) .await @@ -342,6 +347,7 @@ async fn closing_a_bag_surfaces_on_the_timeline() { country: "UK".to_string(), city: Some("Bristol".to_string()), homepage: Some("https://example.com".to_string()), + created_at: None, }, ) .await @@ -475,6 +481,7 @@ async fn creating_a_cafe_surfaces_on_the_timeline() { latitude: 51.4545, longitude: -2.5879, website: Some("https://example.com".to_string()), + created_at: None, }, ) .await; @@ -627,6 +634,7 @@ async fn creating_a_brew_surfaces_on_the_timeline() { water_volume: 250, water_temp: 92.0, quick_notes: Vec::new(), + created_at: None, }; let response = client