✅ Revisa el estado de los tests del entorno
This commit is contained in:
parent
736e1be6ea
commit
c6800e4387
13 changed files with 46 additions and 13 deletions
|
|
@ -47,3 +47,6 @@ pagetop-macros.workspace = true
|
|||
|
||||
[build-dependencies]
|
||||
pagetop-build.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
serde_json.workspace = true
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ macro_rules! hm {
|
|||
///
|
||||
/// # Ejemplo
|
||||
///
|
||||
/// ```
|
||||
/// ```rust#ignore
|
||||
/// // Concatena todos los fragmentos directamente.
|
||||
/// let result = join_string!("Hello", " ", "World");
|
||||
/// assert_eq!(result, "Hello World".to_string());
|
||||
|
|
@ -206,7 +206,7 @@ macro_rules! join_string {
|
|||
///
|
||||
/// # Ejemplo
|
||||
///
|
||||
/// ```
|
||||
/// ```rust#ignore
|
||||
/// // Concatena los fragmentos no vacíos con un espacio como separador.
|
||||
/// let result_with_separator = option_string!(["Hello", "", "World"]; " ");
|
||||
/// assert_eq!(result_with_separator, Some("Hello World".to_string()));
|
||||
|
|
@ -244,7 +244,7 @@ macro_rules! option_string {
|
|||
///
|
||||
/// # Ejemplo
|
||||
///
|
||||
/// ```
|
||||
/// ```rust#ignore
|
||||
/// let first = "Hello";
|
||||
/// let separator = "-";
|
||||
/// let second = "World";
|
||||
|
|
|
|||
1
pagetop/tests/html/mod.rs
Normal file
1
pagetop/tests/html/mod.rs
Normal file
|
|
@ -0,0 +1 @@
|
|||
mod unit;
|
||||
27
pagetop/tests/html/unit.rs
Normal file
27
pagetop/tests/html/unit.rs
Normal 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
5
pagetop/tests/main.rs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#[cfg(test)]
|
||||
mod server;
|
||||
|
||||
#[cfg(test)]
|
||||
mod html;
|
||||
12
pagetop/tests/server/health_check.rs
Normal file
12
pagetop/tests/server/health_check.rs
Normal 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;
|
||||
}
|
||||
1
pagetop/tests/server/mod.rs
Normal file
1
pagetop/tests/server/mod.rs
Normal file
|
|
@ -0,0 +1 @@
|
|||
mod health_check;
|
||||
Loading…
Add table
Add a link
Reference in a new issue