rjango 0.1.1

A full-stack Rust backend framework inspired by Django
Documentation
pub use super::resolvers::NoReverseMatch;
use thiserror::Error;

#[derive(Debug, Clone, PartialEq, Eq, Error)]
#[error("Resolver404: {path}")]
pub struct Resolver404 {
    pub path: String,
}

impl Resolver404 {
    #[must_use]
    pub fn new(path: impl Into<String>) -> Self {
        Self { path: path.into() }
    }
}

#[cfg(test)]
mod tests {
    use super::{NoReverseMatch, Resolver404};

    #[test]
    fn no_reverse_match_reexport_uses_canonical_error_shape() {
        let error = NoReverseMatch {
            name: "dashboard".to_string(),
        };

        assert_eq!(error.to_string(), "Reverse for 'dashboard' not found");
    }

    #[test]
    fn no_reverse_match_reexport_preserves_name_field() {
        let error = NoReverseMatch {
            name: "detail".to_string(),
        };

        assert_eq!(error.name, "detail");
    }

    #[test]
    fn resolver_404_constructor_stores_path() {
        let error = Resolver404::new("/missing/");

        assert_eq!(error.path, "/missing/");
    }

    #[test]
    fn resolver_404_formats_path() {
        let error = Resolver404::new("/gone/");

        assert_eq!(error.to_string(), "Resolver404: /gone/");
    }
}