Incorpora y revisa código para pruebas unitarias

This commit is contained in:
Manuel Cillero 2024-12-05 14:32:10 +01:00
parent 7bf89ca90d
commit c5b0c529ef
9 changed files with 31 additions and 14 deletions

View file

@ -17,7 +17,7 @@ use syn::{parse_macro_input, parse_str, DeriveInput, ItemFn};
///
/// # Ejemplos
///
/// ```
/// ```rust#ignore
/// #[fn_builder]
/// pub fn set_example(&mut self) -> &mut Self {
/// // implementación
@ -26,7 +26,7 @@ use syn::{parse_macro_input, parse_str, DeriveInput, ItemFn};
///
/// Añadirá al código el siguiente método:
///
/// ```
/// ```rust#ignore
/// #[inline]
/// pub fn with_example(mut self) -> Self {
/// self.set_example();
@ -159,7 +159,7 @@ pub fn derive_component_classes(input: TokenStream) -> TokenStream {
///
/// # Ejemplos
///
/// ```
/// ```rust#ignore
/// #[pagetop::main]
/// async fn main() {
/// async { println!("Hello world!"); }.await
@ -180,7 +180,7 @@ pub fn main(_: TokenStream, item: TokenStream) -> TokenStream {
///
/// # Ejemplos
///
/// ```
/// ```rust#ignore
/// #[pagetop::test]
/// async fn test() {
/// assert_eq!(async { "Hello world" }.await, "Hello world");

View file

@ -57,7 +57,7 @@
//! Then, use the [`include_config!`](crate::include_config) macro to initialize your settings with
//! type-safe structures and predefined values:
//!
//! ```
//! ```rust#ignore
//! use pagetop::prelude::*;
//! use serde::Deserialize;
//!
@ -101,7 +101,7 @@
//!
//! Access the settings directly in your code:
//!
//! ```
//! ```rust#ignore
//! use pagetop::prelude::*;
//! use crate::config;
//!

View file

@ -34,7 +34,7 @@ mod escape;
///
/// # Example
///
/// ```rust
/// ```rust#ignore
/// use maud::Escaper;
/// use std::fmt::Write;
/// let mut s = String::new();
@ -72,7 +72,7 @@ impl<'a> fmt::Write for Escaper<'a> {
///
/// # Example
///
/// ```rust
/// ```rust#ignore
/// use maud::{html, Markup, Render};
///
/// /// Provides a shorthand for linking to a CSS stylesheet.
@ -188,7 +188,7 @@ impl_render_with_itoa! {
///
/// # Example
///
/// ```rust
/// ```rust#ignore
/// use maud::html;
/// use std::net::Ipv4Addr;
///
@ -259,7 +259,7 @@ impl<T: AsRef<str> + Default> Default for PreEscaped<T> {
///
/// A minimal web page:
///
/// ```rust
/// ```rust#ignore
/// use maud::{DOCTYPE, html};
///
/// let markup = html! {

View file

@ -29,7 +29,7 @@
//!
//! # ⚡️ Quick start
//!
//! ```rust
//! ```rust#ignore
//! use pagetop::prelude::*;
//!
//! struct HelloWorld;

View file

@ -70,7 +70,7 @@
//! [`include_locales!`](crate::include_locales) macro to integrate them into your module or
//! application. If your resources are located in the `"src/locale"` directory, simply declare:
//!
//! ```
//! ```rust#ignore
//! use pagetop::prelude::*;
//!
//! include_locales!(LOCALES_SAMPLE);
@ -78,7 +78,7 @@
//!
//! But if they are in another directory, then you can use:
//!
//! ```
//! ```rust#ignore
//! use pagetop::prelude::*;
//!
//! include_locales!(LOCALES_SAMPLE from "path/to/locale");

View file

@ -103,7 +103,7 @@ impl TypeInfo {
///
/// # Examples
///
/// ```
/// ```rust#ignore
/// let root = "/home/user";
/// let relative = "documents";
/// let abs_dir = absolute_dir(root, relative).unwrap();

2
tests/main.rs Normal file
View file

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

View file

@ -0,0 +1,14 @@
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;
// assert_eq!("OK", "OK");
}

1
tests/server/mod.rs Normal file
View file

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