✅ (tests): Adapta la suite al nuevo framework web
- Sustituye `service::test::*` por `web::test::*` (migración de actix-web a
axum).
- Extrae `setup()` en los módulos que sólo renderizan componentes,
evitando levantar un router completo en cada test.
- Elimina los `env::set_var("PAGETOP_RUN_MODE", "test")` manuales, ya
cubiertos por la *feature* `testing`.
This commit is contained in:
parent
87e4eac27c
commit
eb18690a5c
6 changed files with 45 additions and 53 deletions
|
|
@ -1,8 +1,16 @@
|
|||
use pagetop::prelude::*;
|
||||
|
||||
/// Inicializa PageTop (locale, extensiones…) una sola vez para toda la suite.
|
||||
///
|
||||
/// Los tests de este módulo renderizan componentes directamente con `Context::default()`, por lo
|
||||
/// que sólo necesitan el subsistema de localización y las extensiones registradas, no un router.
|
||||
fn setup() {
|
||||
let _ = Application::new();
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
async fn poweredby_default_shows_only_pagetop_recognition() {
|
||||
let _app = service::test::init_service(Application::new().test()).await;
|
||||
setup();
|
||||
|
||||
let mut p = PoweredBy::default();
|
||||
let html = p.render(&mut Context::default());
|
||||
|
|
@ -16,7 +24,7 @@ async fn poweredby_default_shows_only_pagetop_recognition() {
|
|||
|
||||
#[pagetop::test]
|
||||
async fn poweredby_new_includes_current_year_and_app_name() {
|
||||
let _app = service::test::init_service(Application::new().test()).await;
|
||||
setup();
|
||||
|
||||
let mut p = PoweredBy::new();
|
||||
let html = p.render(&mut Context::default());
|
||||
|
|
@ -40,7 +48,7 @@ async fn poweredby_new_includes_current_year_and_app_name() {
|
|||
|
||||
#[pagetop::test]
|
||||
async fn poweredby_with_copyright_overrides_text() {
|
||||
let _app = service::test::init_service(Application::new().test()).await;
|
||||
setup();
|
||||
|
||||
let custom = "2001 © FooBar Inc.";
|
||||
let mut p = PoweredBy::default().with_copyright(Some(custom));
|
||||
|
|
@ -52,7 +60,7 @@ async fn poweredby_with_copyright_overrides_text() {
|
|||
|
||||
#[pagetop::test]
|
||||
async fn poweredby_with_copyright_none_hides_text() {
|
||||
let _app = service::test::init_service(Application::new().test()).await;
|
||||
setup();
|
||||
|
||||
let mut p = PoweredBy::new().with_copyright(None::<String>);
|
||||
let html = p.render(&mut Context::default());
|
||||
|
|
@ -64,7 +72,7 @@ async fn poweredby_with_copyright_none_hides_text() {
|
|||
|
||||
#[pagetop::test]
|
||||
async fn poweredby_link_points_to_crates_io() {
|
||||
let _app = service::test::init_service(Application::new().test()).await;
|
||||
setup();
|
||||
|
||||
let mut p = PoweredBy::default();
|
||||
let html = p.render(&mut Context::default());
|
||||
|
|
@ -77,7 +85,7 @@ async fn poweredby_link_points_to_crates_io() {
|
|||
|
||||
#[pagetop::test]
|
||||
async fn poweredby_getter_reflects_internal_state() {
|
||||
let _app = service::test::init_service(Application::new().test()).await;
|
||||
setup();
|
||||
|
||||
// Por defecto no hay copyright.
|
||||
let p0 = PoweredBy::default();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue