您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

22 行
624 B

  1. //! Shared test helpers.
  2. use axum_test::TestServer;
  3. use axum_api_template::{
  4. config::AppConfig,
  5. routes::build_router,
  6. state::AppState,
  7. };
  8. /// Spins up an in-process test server with a minimal config.
  9. pub async fn test_server() -> TestServer {
  10. // Set minimal env vars so AppConfig::load() succeeds.
  11. std::env::set_var("APP_ENV", "development");
  12. let config = AppConfig::load().expect("Failed to load test config");
  13. let state = AppState::new(config).await.expect("Failed to build test state");
  14. let app = build_router(state);
  15. TestServer::new(app).expect("Failed to create test server")
  16. }