From 3267d60f1baea676a20c76801943b0712fceee40 Mon Sep 17 00:00:00 2001 From: Kogia-sima Date: Tue, 14 Jul 2020 18:59:39 +0900 Subject: [PATCH] Add test for configuration file --- Cargo.lock | 1 + integration-tests/Cargo.toml | 1 + integration-tests/config/sailfish.yml | 6 ++++++ integration-tests/tests/config.rs | 13 +++++++++++++ 4 files changed, 21 insertions(+) create mode 100644 integration-tests/config/sailfish.yml create mode 100644 integration-tests/tests/config.rs diff --git a/Cargo.lock b/Cargo.lock index 2e9962d..c48b7bb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -665,6 +665,7 @@ version = "0.1.3" dependencies = [ "pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "sailfish 0.1.3", + "sailfish-compiler 0.1.3", "sailfish-macros 0.1.3", "trybuild 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)", ] diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index 7874aa2..94f3ef3 100644 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -8,6 +8,7 @@ publish = false [dependencies] sailfish = { path = "../sailfish" } sailfish-macros = { path = "../sailfish-macros" } +sailfish-compiler = { path = "../sailfish-compiler" } [dev-dependencies] trybuild = "1.0.28" diff --git a/integration-tests/config/sailfish.yml b/integration-tests/config/sailfish.yml new file mode 100644 index 0000000..c12237c --- /dev/null +++ b/integration-tests/config/sailfish.yml @@ -0,0 +1,6 @@ +template_dir: "../templates" +escape: true +delimiter: "%" + +optimization: + rm_whitespace: false diff --git a/integration-tests/tests/config.rs b/integration-tests/tests/config.rs new file mode 100644 index 0000000..853e726 --- /dev/null +++ b/integration-tests/tests/config.rs @@ -0,0 +1,13 @@ +use sailfish_compiler::Config; +use std::path::Path; + +#[test] +fn read_config() { + let path = Path::new(env!("CARGO_MANIFEST_DIR")).join("config"); + let config = Config::search_file_and_read(&*path).unwrap(); + + assert_eq!(config.delimiter, '%'); + assert_eq!(config.escape, true); + assert_eq!(config.rm_whitespace, false); + assert_eq!(config.template_dirs.len(), 1); +}