aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar vallentin <mail@vallentin.dev>2021-03-10 11:41:30 +0100
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2021-03-10 13:09:56 +0100
commit7b954cd78800b8730401c4471f2289e2d990444f (patch)
tree7a3ddde1acf2c160445104dd08085404b13db1fc
parentd6c05d8eb97389a86780cc1c718eb2fd1ada6c6f (diff)
downloadaskama-7b954cd78800b8730401c4471f2289e2d990444f.tar.gz
askama-7b954cd78800b8730401c4471f2289e2d990444f.tar.bz2
askama-7b954cd78800b8730401c4471f2289e2d990444f.zip
Added path and ext tests
Diffstat (limited to '')
-rw-r--r--testing/templates/foo.html1
-rw-r--r--testing/templates/foo.html.jinja1
-rw-r--r--testing/templates/foo.jinja1
-rw-r--r--testing/tests/ext.rs67
4 files changed, 70 insertions, 0 deletions
diff --git a/testing/templates/foo.html b/testing/templates/foo.html
new file mode 100644
index 0000000..85fa64c
--- /dev/null
+++ b/testing/templates/foo.html
@@ -0,0 +1 @@
+foo.html \ No newline at end of file
diff --git a/testing/templates/foo.html.jinja b/testing/templates/foo.html.jinja
new file mode 100644
index 0000000..dc645f3
--- /dev/null
+++ b/testing/templates/foo.html.jinja
@@ -0,0 +1 @@
+foo.html.jinja \ No newline at end of file
diff --git a/testing/templates/foo.jinja b/testing/templates/foo.jinja
new file mode 100644
index 0000000..f47c4d5
--- /dev/null
+++ b/testing/templates/foo.jinja
@@ -0,0 +1 @@
+foo.jinja \ No newline at end of file
diff --git a/testing/tests/ext.rs b/testing/tests/ext.rs
new file mode 100644
index 0000000..5ed4e72
--- /dev/null
+++ b/testing/tests/ext.rs
@@ -0,0 +1,67 @@
+use askama::Template;
+
+#[derive(Template)]
+#[template(path = "foo.html")]
+struct PathHtml;
+
+#[test]
+fn test_path_ext_html() {
+ let t = PathHtml;
+ assert_eq!(t.render().unwrap(), "foo.html");
+ assert_eq!(t.extension(), Some("html"));
+}
+
+#[derive(Template)]
+#[template(path = "foo.jinja")]
+struct PathJinja;
+
+#[test]
+fn test_path_ext_jinja() {
+ let t = PathJinja;
+ assert_eq!(t.render().unwrap(), "foo.jinja");
+ assert_eq!(t.extension(), Some("jinja"));
+}
+
+#[derive(Template)]
+#[template(path = "foo.html.jinja")]
+struct PathHtmlJinja;
+
+#[test]
+fn test_path_ext_html_jinja() {
+ let t = PathHtmlJinja;
+ assert_eq!(t.render().unwrap(), "foo.html.jinja");
+ assert_eq!(t.extension(), Some("html"));
+}
+
+#[derive(Template)]
+#[template(path = "foo.html", ext = "txt")]
+struct PathHtmlAndExtTxt;
+
+#[test]
+fn test_path_ext_html_and_ext_txt() {
+ let t = PathHtmlAndExtTxt;
+ assert_eq!(t.render().unwrap(), "foo.html");
+ assert_eq!(t.extension(), Some("txt"));
+}
+
+#[derive(Template)]
+#[template(path = "foo.jinja", ext = "txt")]
+struct PathJinjaAndExtTxt;
+
+#[test]
+fn test_path_ext_jinja_and_ext_txt() {
+ let t = PathJinjaAndExtTxt;
+ assert_eq!(t.render().unwrap(), "foo.jinja");
+ assert_eq!(t.extension(), Some("txt"));
+}
+
+#[derive(Template)]
+#[template(path = "foo.html.jinja", ext = "txt")]
+struct PathHtmlJinjaAndExtTxt;
+
+#[test]
+fn test_path_ext_html_jinja_and_ext_txt() {
+ let t = PathHtmlJinjaAndExtTxt;
+ assert_eq!(t.render().unwrap(), "foo.html.jinja");
+ assert_eq!(t.extension(), Some("txt"));
+}