added tests for str mode
This commit is contained in:
parent
d025c3c120
commit
aac8787410
35
tests/str.rs
Normal file
35
tests/str.rs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
use dir_embed::Embed;
|
||||||
|
|
||||||
|
#[derive(Embed)]
|
||||||
|
#[dir = "./../testdata/"]
|
||||||
|
#[mode = "str"]
|
||||||
|
pub struct Assets;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn str_get() {
|
||||||
|
assert!(Assets::get("file1.txt").is_some());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn str_get_missing() {
|
||||||
|
assert!(Assets::get("missing.txt").is_none());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn str_read_content() {
|
||||||
|
let content_should = "file1";
|
||||||
|
let content_is = Assets::get("file1.txt").unwrap();
|
||||||
|
assert_eq!(content_is, content_should);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn str_sub_directories_get() {
|
||||||
|
assert!(Assets::get("sub/file2.txt").is_some());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn str_sub_directories_content() {
|
||||||
|
let content_should = "file2";
|
||||||
|
let content_is = Assets::get("sub/file2.txt").unwrap();
|
||||||
|
assert_eq!(content_is, content_should);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user