test: Improve `template_not_found` test to detect stable/nightly mismatch error

cc #50
This commit is contained in:
Kogia-sima 2021-02-03 15:58:51 +09:00
parent 10ab29be85
commit 2cc9556dbe
3 changed files with 10 additions and 13 deletions

View File

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

View File

@ -1,26 +1,18 @@
error: Template file "not_exist.stpl" not found
--> $DIR/template_not_found.rs:5:19
--> $DIR/template_not_found.rs:9:19
|
5 | #[template(path = "not_exist.stpl")]
9 | #[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
--> $DIR/template_not_found.rs:16:51
|
6 | struct NotExistTemplate {
10 | struct NotExistTemplate {
| ----------------------- method `render_once` not found for this
...
11 | println!("{}", NotExistTemplate { var: 1996 }.render_once().unwrap());
16 | 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