Update clippy improvements

This commit is contained in:
Altuğ Bakan 2023-10-07 13:10:53 +02:00
parent 83b1387cd7
commit 64f7e0f7ef
2 changed files with 7 additions and 10 deletions

View file

@ -108,7 +108,7 @@ mod tests {
#[test]
fn parses_full_config() {
let config = Config::new(
vec!["/", "-i", "0.0.0.0", "-p", "1234", "-d", "/", "-s", "-r"]
["/", "-i", "0.0.0.0", "-p", "1234", "-d", "/", "-s", "-r"]
.iter()
.map(|s| s.to_string()),
)
@ -124,7 +124,7 @@ mod tests {
#[test]
fn parses_some_config() {
let config = Config::new(
vec!["/", "-i", "0.0.0.0", "-d", "/"]
["/", "-i", "0.0.0.0", "-d", "/"]
.iter()
.map(|s| s.to_string()),
)
@ -138,7 +138,7 @@ mod tests {
#[test]
fn returns_error_on_invalid_ip() {
assert!(Config::new(
vec!["/", "-i", "1234.5678.9012.3456"]
["/", "-i", "1234.5678.9012.3456"]
.iter()
.map(|s| s.to_string()),
)
@ -147,13 +147,13 @@ mod tests {
#[test]
fn returns_error_on_invalid_port() {
assert!(Config::new(vec!["/", "-p", "1234567"].iter().map(|s| s.to_string()),).is_err());
assert!(Config::new(["/", "-p", "1234567"].iter().map(|s| s.to_string()),).is_err());
}
#[test]
fn returns_error_on_invalid_directory() {
assert!(Config::new(
vec!["/", "-d", "/this/does/not/exist"]
["/", "-d", "/this/does/not/exist"]
.iter()
.map(|s| s.to_string()),
)

View file

@ -120,7 +120,6 @@ mod tests {
use std::{
fs::{self, OpenOptions},
io::{Seek, Write},
path::Path,
};
const DIR_NAME: &str = "tmp";
@ -190,10 +189,8 @@ mod tests {
fn initialize(file_name: &str) -> File {
let file_name = DIR_NAME.to_string() + "/" + file_name;
if !Path::new(DIR_NAME).is_dir() {
if fs::create_dir(DIR_NAME).is_err() {
}
}
let _ = fs::create_dir_all(DIR_NAME);
if File::open(&file_name).is_ok() {
fs::remove_file(&file_name).unwrap();