+
+ {{ content }}
+
+
+
diff --git a/tests/fixtures/timestamp/_layouts/posts.liquid b/tests/fixtures/timestamp/_layouts/posts.liquid
new file mode 100644
index 00000000..46d21c6d
--- /dev/null
+++ b/tests/fixtures/timestamp/_layouts/posts.liquid
@@ -0,0 +1,10 @@
+
+
+
+ My blog - {{ title }}
+
+
+ {{ content }}
+
+
+
diff --git a/tests/fixtures/timestamp/index.liquid b/tests/fixtures/timestamp/index.liquid
new file mode 100644
index 00000000..93de6018
--- /dev/null
+++ b/tests/fixtures/timestamp/index.liquid
@@ -0,0 +1,7 @@
+extends: default.liquid
+---
+This is my Index page!
+
+{% for post in posts %}
+ {{ post.title }}
+{% endfor %}
diff --git a/tests/fixtures/timestamp/posts/2014-08-24-my-first-blogpost.md b/tests/fixtures/timestamp/posts/2014-08-24-my-first-blogpost.md
new file mode 100644
index 00000000..982e38c4
--- /dev/null
+++ b/tests/fixtures/timestamp/posts/2014-08-24-my-first-blogpost.md
@@ -0,0 +1,10 @@
+extends: posts.liquid
+
+title: My first Blogpost
+date: 24/08/2014 at 15:36
+---
+# {{ title }}
+
+Hey there this is my first blogpost and this is super awesome.
+
+My Blog is lorem ipsum like, yes it is..
diff --git a/tests/mod.rs b/tests/mod.rs
index da93efed..ea95a771 100644
--- a/tests/mod.rs
+++ b/tests/mod.rs
@@ -3,6 +3,8 @@ extern crate difference;
extern crate cobalt;
extern crate tempdir;
extern crate walkdir;
+extern crate chrono;
+extern crate regex;
use std::path::Path;
use std::fs::{self, File};
@@ -11,6 +13,8 @@ use tempdir::TempDir;
use walkdir::WalkDir;
use std::error::Error;
use cobalt::Config;
+use chrono::UTC;
+use regex::Regex;
fn run_test(name: &str) -> Result<(), cobalt::Error> {
let target = format!("tests/target/{}/", name);
@@ -226,3 +230,32 @@ pub fn empty_frontmatter() {
pub fn querystrings() {
run_test("querystrings").expect("Build error");
}
+
+#[test]
+pub fn timestamp() {
+ // timestamp adds current ms time so need to build the target folder at run time
+ let mut config = Config::from_file("tests/fixtures/timestamp/.cobalt.yml").unwrap_or_default();
+ config.source = "tests/fixtures/timestamp/".to_string();
+ config.dest = "tests/target/timestamp/".to_string();
+
+ fs::create_dir_all(&config.dest).is_ok();
+
+ let timestamp = UTC::now().timestamp().to_string();
+ let result = cobalt::build(&config);
+
+ if result.is_ok() {
+ // check timestamp is in the target layout
+ let mut content = String::new();
+ let _file = File::open("tests/target/timestamp/index.html")
+ .unwrap()
+ .read_to_string(&mut content);
+ let re = Regex::new(×tamp.as_str()).unwrap();
+ assert!(re.is_match(&content.as_str()));
+
+ // run standard test to make sure it doesn't fall over
+ run_test("timestamp").expect("Build error");
+
+ // delete file with timestamp otherwise next test build will fail
+ let _deleted = fs::remove_file("tests/target/timestamp/index.html");
+ }
+}
\ No newline at end of file
diff --git a/tests/target/timestamp/posts/2014-08-24-my-first-blogpost.html b/tests/target/timestamp/posts/2014-08-24-my-first-blogpost.html
new file mode 100644
index 00000000..163d0665
--- /dev/null
+++ b/tests/target/timestamp/posts/2014-08-24-my-first-blogpost.html
@@ -0,0 +1,13 @@
+
+
+
+ My blog - My first Blogpost
+
+
+
My first Blogpost
+
Hey there this is my first blogpost and this is super awesome.