test: Add tests for missing tempaltes

cc #50
This commit is contained in:
Kogia-sima 2021-02-03 00:52:21 +09:00
parent 47818c11b7
commit 5c5c57f437
2 changed files with 38 additions and 0 deletions

View File

@ -0,0 +1,12 @@
use sailfish::TemplateOnce;
use sailfish_macros::TemplateOnce;
#[derive(TemplateOnce)]
#[template(path = "not_exist.stpl")]
struct NotExistTemplate {
var: usize
}
fn main() {
println!("{}", NotExistTemplate { var: 1996 }.render_once().unwrap());
}

View File

@ -0,0 +1,26 @@
error: Template file "not_exist.stpl" not found
--> $DIR/template_not_found.rs:5:19
|
5 | #[template(path = "not_exist.stpl")]
| ^^^^^^^^^^^^^^^^
error[E0599]: no method named `render_once` found for struct `NotExistTemplate` in the current scope
--> $DIR/template_not_found.rs:11:51
|
6 | struct NotExistTemplate {
| ----------------------- method `render_once` not found for this
...
11 | println!("{}", NotExistTemplate { var: 1996 }.render_once().unwrap());
| ^^^^^^^^^^^ method not found in `NotExistTemplate`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `render_once`, perhaps you need to implement it:
candidate #1: `TemplateOnce`
warning: unused import: `sailfish::TemplateOnce`
--> $DIR/template_not_found.rs:1:5
|
1 | use sailfish::TemplateOnce;
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default