From afee9b771b28fe4f8f5f7a687cb7a50d82a3f707 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Thu, 12 Jul 2018 13:30:05 +0100 Subject: Add some tests for Config contents --- askama_shared/src/lib.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'askama_shared/src') diff --git a/askama_shared/src/lib.rs b/askama_shared/src/lib.rs index e9b368e..bff7b57 100644 --- a/askama_shared/src/lib.rs +++ b/askama_shared/src/lib.rs @@ -80,6 +80,22 @@ mod tests { use std::env; use std::path::{Path, PathBuf}; + #[test] + fn test_default_config() { + let mut root = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()); + root.push("templates"); + let config = Config::from_str(""); + assert_eq!(config.dirs, vec![root]); + } + + #[test] + fn test_config_dirs() { + let mut root = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()); + root.push("tpl"); + let config = Config::from_str("dirs = [\"tpl\"]"); + assert_eq!(config.dirs, vec![root]); + } + fn assert_eq_rooted(actual: &Path, expected: &str) { let mut root = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()); root.push("templates"); -- cgit