SPlit up
This commit is contained in:
parent
cf39ad754e
commit
f59d01227b
91 changed files with 10370 additions and 7562 deletions
|
|
@ -87,6 +87,105 @@ pub struct AppState {
|
|||
pub bugsink_frontend_config: Option<BugsinkFrontendConfig>,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
impl AppState {
|
||||
/// Minimal AppState for integration tests of the PocketBase/Stripe money
|
||||
/// paths (checkout, webhook, licensing, invites). All map/property data is
|
||||
/// empty; only the HTTP-facing config (PocketBase URL, Stripe secrets,
|
||||
/// caches) carries meaningful values.
|
||||
pub(crate) fn for_tests(pocketbase_url: String) -> Self {
|
||||
use std::time::Duration;
|
||||
|
||||
use crate::data::{
|
||||
ActualListingData, CrimeByYearData, OutcodeData, POIData, PlaceData, PostcodeData,
|
||||
PropertyData, TravelTimeStore,
|
||||
};
|
||||
use crate::utils::InternedColumn;
|
||||
|
||||
let http_client = reqwest::Client::builder()
|
||||
.timeout(Duration::from_secs(5))
|
||||
.connect_timeout(Duration::from_secs(2))
|
||||
.build()
|
||||
.expect("test HTTP client should build");
|
||||
|
||||
AppState {
|
||||
data: PropertyData::empty_for_tests(),
|
||||
grid: GridIndex::build(&[], &[], 0.01),
|
||||
h3_cells: Vec::new(),
|
||||
feature_name_to_index: FxHashMap::default(),
|
||||
min_keys: Vec::new(),
|
||||
max_keys: Vec::new(),
|
||||
avg_keys: Vec::new(),
|
||||
features_response: FeaturesResponse { groups: Vec::new() },
|
||||
ai_filters_system_prompt: String::new(),
|
||||
poi_data: Arc::new(POIData::empty_for_tests()),
|
||||
poi_grid: Arc::new(GridIndex::build(&[], &[], 0.01)),
|
||||
place_data: Arc::new(PlaceData::empty_for_tests()),
|
||||
postcode_data: Arc::new(PostcodeData {
|
||||
postcodes: Vec::new(),
|
||||
centroids: Vec::new(),
|
||||
aabbs: Vec::new(),
|
||||
polygons: Vec::new(),
|
||||
postcode_to_idx: FxHashMap::default(),
|
||||
}),
|
||||
outcode_data: Arc::new(OutcodeData {
|
||||
names: Vec::new(),
|
||||
name_lower: Vec::new(),
|
||||
centroids: Vec::new(),
|
||||
cities: Vec::new(),
|
||||
}),
|
||||
poi_category_groups: Arc::new(Vec::new()),
|
||||
travel_time_store: Arc::new(TravelTimeStore::empty_for_tests()),
|
||||
actual_listings: Arc::new(ActualListingData {
|
||||
lat: Vec::new(),
|
||||
lon: Vec::new(),
|
||||
postcode: Vec::new(),
|
||||
address: Vec::new(),
|
||||
property_type: InternedColumn::build(&[]),
|
||||
property_sub_type: InternedColumn::build(&[]),
|
||||
leasehold_freehold: InternedColumn::build(&[]),
|
||||
price_qualifier: InternedColumn::build(&[]),
|
||||
bedrooms: Vec::new(),
|
||||
bathrooms: Vec::new(),
|
||||
rooms_total: Vec::new(),
|
||||
floor_area_sqm: Vec::new(),
|
||||
asking_price: Vec::new(),
|
||||
asking_price_per_sqm: Vec::new(),
|
||||
listing_url: Vec::new(),
|
||||
listing_status: InternedColumn::build(&[]),
|
||||
listing_date_iso: Vec::new(),
|
||||
features: Vec::new(),
|
||||
filter_feature_data: Vec::new(),
|
||||
poi_filter_feature_data: Vec::new(),
|
||||
grid: GridIndex::build(&[], &[], 0.01),
|
||||
}),
|
||||
crime_by_year: Arc::new(CrimeByYearData {
|
||||
crime_types: Vec::new(),
|
||||
years_by_type: Vec::new(),
|
||||
series_by_postcode: FxHashMap::default(),
|
||||
covered_years_by_postcode: FxHashMap::default(),
|
||||
}),
|
||||
token_cache: Arc::new(TokenCache::new()),
|
||||
superuser_token_cache: Arc::new(SuperuserTokenCache::new()),
|
||||
share_cache: Arc::new(ShareBoundsCache::new()),
|
||||
screenshot_url: "http://127.0.0.1:1/screenshot".to_string(),
|
||||
public_url: "https://test.example".to_string(),
|
||||
is_dev: false,
|
||||
http_client,
|
||||
pocketbase_url,
|
||||
pocketbase_admin_email: "admin@test.example".to_string(),
|
||||
pocketbase_admin_password: "test-admin-password".to_string(),
|
||||
gemini_api_key: "test-gemini-key".to_string(),
|
||||
gemini_model: "test-model".to_string(),
|
||||
google_maps_api_key: "test-maps-key".to_string(),
|
||||
stripe_secret_key: "sk_test_dummy".to_string(),
|
||||
stripe_webhook_secret: "whsec_test_secret".to_string(),
|
||||
stripe_referral_coupon_id: "couponTest30".to_string(),
|
||||
bugsink_frontend_config: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Wraps AppState for shared access across route handlers.
|
||||
/// Route handlers call `load_state()` to get the current snapshot.
|
||||
pub struct SharedState {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue