Revisa el estado de los tests del entorno

This commit is contained in:
Manuel Cillero 2025-01-04 08:31:31 +01:00
parent 7b0f9a91f2
commit 24bf63b039
13 changed files with 46 additions and 13 deletions

View file

@ -0,0 +1 @@
mod unit;

View file

@ -0,0 +1,27 @@
use pagetop::prelude::*;
use serde_json;
#[pagetop::test]
async fn test_deserialize_absolute_units() {
let value: unit::Value = serde_json::from_str("\"50px\"").unwrap();
assert!(matches!(value, unit::Value::Px(50)));
let value: unit::Value = serde_json::from_str("\"10cm\"").unwrap();
assert!(matches!(value, unit::Value::Cm(10)));
}
#[pagetop::test]
async fn test_deserialize_relative_units() {
let value: unit::Value = serde_json::from_str("\"1.5em\"").unwrap();
assert!(matches!(value, unit::Value::RelEm(1.5)));
let value: unit::Value = serde_json::from_str("\"100%\"").unwrap();
assert!(matches!(value, unit::Value::RelPct(100.0)));
}
#[pagetop::test]
async fn test_invalid_format() {
let result: Result<unit::Value, _> = serde_json::from_str("\"invalid\"");
assert!(result.is_err());
}

5
pagetop/tests/main.rs Normal file
View file

@ -0,0 +1,5 @@
#[cfg(test)]
mod server;
#[cfg(test)]
mod html;

View file

@ -0,0 +1,12 @@
use pagetop::prelude::*;
struct HealthCheck;
impl PackageTrait for HealthCheck {}
#[pagetop::test]
async fn health_check_works() {
let app = service::test::init_service(Application::prepare(&HealthCheck).test()).await;
let req = service::test::TestRequest::get().uri("/").to_request();
let _resp = service::test::call_service(&app, req).await;
}

View file

@ -0,0 +1 @@
mod health_check;