Skip to content

Commit 4b0a91f

Browse files
test: add tests for correct parsing of ignore directories
1 parent 08fde53 commit 4b0a91f

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

static-serve-macro/src/lib.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,3 +414,35 @@ fn etag(contents: &[u8]) -> String {
414414
^ u64::from_le_bytes(sha256[8..16].try_into().unwrap());
415415
format!("\"{hash:016x}\"")
416416
}
417+
418+
#[cfg(test)]
419+
mod test {
420+
use quote::quote;
421+
use syn::parse2;
422+
423+
use crate::IgnoreDirsWithSpan;
424+
425+
#[test]
426+
fn handles_ident_ignoredirs() {
427+
let res = parse2::<IgnoreDirsWithSpan>(quote! {[big]});
428+
assert!(res.is_ok());
429+
}
430+
431+
#[test]
432+
fn handles_litstr_ignoredirs() {
433+
let res = parse2::<IgnoreDirsWithSpan>(quote! {["big"]});
434+
assert!(res.is_ok());
435+
}
436+
437+
#[test]
438+
fn errors_on_invalid_ignoredir() {
439+
let res = parse2::<IgnoreDirsWithSpan>(quote! {[2]});
440+
assert!(res.is_err());
441+
}
442+
443+
#[test]
444+
fn errors_on_ignoredirs_one_invalid() {
445+
let res = parse2::<IgnoreDirsWithSpan>(quote! {[big, 2]});
446+
assert!(res.is_err());
447+
}
448+
}

0 commit comments

Comments
 (0)