huskies: merge 950

This commit is contained in:
dave
2026-05-13 08:46:22 +00:00
parent 7491eec257
commit 4a8ed4348b
38 changed files with 354 additions and 4329 deletions
-12
View File
@@ -1,21 +1,9 @@
//! Shared test utilities for HTTP handler tests.
//!
//! Import with `use crate::http::test_helpers::{make_api, test_ctx};`
use crate::http::context::AppContext;
use std::path::Path;
use std::sync::Arc;
use tempfile::TempDir;
/// Build an [`AppContext`] rooted at `dir` for use in tests.
pub(crate) fn test_ctx(dir: &Path) -> AppContext {
AppContext::new_test(dir.to_path_buf())
}
/// Build an API struct rooted in `dir` for use in tests.
///
/// Requires the API type to implement `From<Arc<AppContext>>`. Add a
/// `#[cfg(test)]` impl block to each API struct to opt in.
pub(crate) fn make_api<T: From<Arc<AppContext>>>(dir: &TempDir) -> T {
Arc::new(test_ctx(dir.path())).into()
}