Skip to content

Commit

Permalink
Merge pull request #660 from sunng87/fix/clippy-warnigns-on-features
Browse files Browse the repository at this point in the history
fix: clippy warnings on optional feature tests
  • Loading branch information
sunng87 authored Jul 15, 2024
2 parents 98d51a1 + 03ed544 commit 5848265
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 32 deletions.
6 changes: 3 additions & 3 deletions src/helpers/scripting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ mod test {
[{"name": "tomcat"}, {"name": "jetty"}]
};

let d0 = to_dynamic(&j0).unwrap();
let d0 = to_dynamic(j0).unwrap();
assert_eq!("array", d0.type_name());

let j1 = json!({
"name": "tomcat",
"value": 4000,
});

let d1 = to_dynamic(&j1).unwrap();
let d1 = to_dynamic(j1).unwrap();
assert_eq!("map", d1.type_name());
}

Expand All @@ -97,7 +97,7 @@ mod test {
let engine = Engine::new();

let script = "let plen = len(params); let p0 = params[0]; let hlen = len(hash); let hme = hash[\"me\"]; plen + \",\" + p0 + \",\" + hlen + \",\" + hme";
let ast = engine.compile(&script).unwrap();
let ast = engine.compile(script).unwrap();

let params = vec![PathAndJson::new(None, ScopedJson::Derived(json!(true)))];

Expand Down
58 changes: 29 additions & 29 deletions src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -907,29 +907,29 @@ mod test {
assert_eq!(r.templates.len(), 0);

let file1_path = dir.path().join("t1.hbs");
let mut file1: File = File::create(&file1_path).unwrap();
let mut file1: File = File::create(file1_path).unwrap();
writeln!(file1, "<h1>Hello {{world}}!</h1>").unwrap();

let file2_path = dir.path().join("t2.hbs");
let mut file2: File = File::create(&file2_path).unwrap();
let mut file2: File = File::create(file2_path).unwrap();
writeln!(file2, "<h1>Hola {{world}}!</h1>").unwrap();

let file3_path = dir.path().join("t3.hbs");
let mut file3: File = File::create(&file3_path).unwrap();
let mut file3: File = File::create(file3_path).unwrap();
writeln!(file3, "<h1>Hallo {{world}}!</h1>").unwrap();

let file4_path = dir.path().join(".t4.hbs");
let mut file4: File = File::create(&file4_path).unwrap();
let mut file4: File = File::create(file4_path).unwrap();
writeln!(file4, "<h1>Hallo {{world}}!</h1>").unwrap();

r.register_templates_directory(dir.path(), DirectorySourceOptions::default())
.unwrap();

assert_eq!(r.templates.len(), 3);
assert_eq!(r.templates.contains_key("t1"), true);
assert_eq!(r.templates.contains_key("t2"), true);
assert_eq!(r.templates.contains_key("t3"), true);
assert_eq!(r.templates.contains_key("t4"), false);
assert!(r.templates.contains_key("t1"));
assert!(r.templates.contains_key("t2"));
assert!(r.templates.contains_key("t3"));
assert!(!r.templates.contains_key("t4"));

drop(file1);
drop(file2);
Expand All @@ -942,22 +942,22 @@ mod test {
let dir = tempdir().unwrap();

let file1_path = dir.path().join("t4.hbs");
let mut file1: File = File::create(&file1_path).unwrap();
let mut file1: File = File::create(file1_path).unwrap();
writeln!(file1, "<h1>Hello {{world}}!</h1>").unwrap();

let file2_path = dir.path().join("t5.erb");
let mut file2: File = File::create(&file2_path).unwrap();
let mut file2: File = File::create(file2_path).unwrap();
writeln!(file2, "<h1>Hello {{% world %}}!</h1>").unwrap();

let file3_path = dir.path().join("t6.html");
let mut file3: File = File::create(&file3_path).unwrap();
let mut file3: File = File::create(file3_path).unwrap();
writeln!(file3, "<h1>Hello world!</h1>").unwrap();

r.register_templates_directory(dir.path(), DirectorySourceOptions::default())
.unwrap();

assert_eq!(r.templates.len(), 4);
assert_eq!(r.templates.contains_key("t4"), true);
assert!(r.templates.contains_key("t4"));

drop(file1);
drop(file2);
Expand All @@ -969,33 +969,33 @@ mod test {
{
let dir = tempdir().unwrap();

let _ = DirBuilder::new().create(dir.path().join("french")).unwrap();
let _ = DirBuilder::new()
DirBuilder::new().create(dir.path().join("french")).unwrap();
DirBuilder::new()
.create(dir.path().join("portugese"))
.unwrap();
let _ = DirBuilder::new()
DirBuilder::new()
.create(dir.path().join("italian"))
.unwrap();

let file1_path = dir.path().join("french/t7.hbs");
let mut file1: File = File::create(&file1_path).unwrap();
let mut file1: File = File::create(file1_path).unwrap();
writeln!(file1, "<h1>Bonjour {{world}}!</h1>").unwrap();

let file2_path = dir.path().join("portugese/t8.hbs");
let mut file2: File = File::create(&file2_path).unwrap();
let mut file2: File = File::create(file2_path).unwrap();
writeln!(file2, "<h1>Ola {{world}}!</h1>").unwrap();

let file3_path = dir.path().join("italian/t9.hbs");
let mut file3: File = File::create(&file3_path).unwrap();
let mut file3: File = File::create(file3_path).unwrap();
writeln!(file3, "<h1>Ciao {{world}}!</h1>").unwrap();

r.register_templates_directory(dir.path(), DirectorySourceOptions::default())
.unwrap();

assert_eq!(r.templates.len(), 7);
assert_eq!(r.templates.contains_key("french/t7"), true);
assert_eq!(r.templates.contains_key("portugese/t8"), true);
assert_eq!(r.templates.contains_key("italian/t9"), true);
assert!(r.templates.contains_key("french/t7"));
assert!(r.templates.contains_key("portugese/t8"));
assert!(r.templates.contains_key("italian/t9"));

drop(file1);
drop(file2);
Expand All @@ -1008,21 +1008,21 @@ mod test {
let dir = tempdir().unwrap();

let file1_path = dir.path().join("t10.hbs");
let mut file1: File = File::create(&file1_path).unwrap();
let mut file1: File = File::create(file1_path).unwrap();
writeln!(file1, "<h1>Bonjour {{world}}!</h1>").unwrap();

let mut dir_path = dir
.path()
.to_string_lossy()
.replace(std::path::MAIN_SEPARATOR, "/");
if !dir_path.ends_with("/") {
if !dir_path.ends_with('/') {
dir_path.push('/');
}
r.register_templates_directory(dir_path, DirectorySourceOptions::default())
.unwrap();

assert_eq!(r.templates.len(), 8);
assert_eq!(r.templates.contains_key("t10"), true);
assert!(r.templates.contains_key("t10"));

drop(file1);
dir.close().unwrap();
Expand All @@ -1033,14 +1033,14 @@ mod test {
let mut r = Registry::new();

let file1_path = dir.path().join("t11.hbs.html");
let mut file1: File = File::create(&file1_path).unwrap();
let mut file1: File = File::create(file1_path).unwrap();
writeln!(file1, "<h1>Bonjour {{world}}!</h1>").unwrap();

let mut dir_path = dir
.path()
.to_string_lossy()
.replace(std::path::MAIN_SEPARATOR, "/");
if !dir_path.ends_with("/") {
if !dir_path.ends_with('/') {
dir_path.push('/');
}
r.register_templates_directory(
Expand All @@ -1053,7 +1053,7 @@ mod test {
.unwrap();

assert_eq!(r.templates.len(), 1);
assert_eq!(r.templates.contains_key("t11"), true);
assert!(r.templates.contains_key("t11"));

drop(file1);
dir.close().unwrap();
Expand All @@ -1066,7 +1066,7 @@ mod test {
assert_eq!(r.templates.len(), 0);

let file1_path = dir.path().join(".t12.hbs");
let mut file1: File = File::create(&file1_path).unwrap();
let mut file1: File = File::create(file1_path).unwrap();
writeln!(file1, "<h1>Hello {{world}}!</h1>").unwrap();

r.register_templates_directory(
Expand All @@ -1079,7 +1079,7 @@ mod test {
.unwrap();

assert_eq!(r.templates.len(), 1);
assert_eq!(r.templates.contains_key(".t12"), true);
assert!(r.templates.contains_key(".t12"));

drop(file1);

Expand Down

0 comments on commit 5848265

Please sign in to comment.