Replace tempdir with tempfile

This commit is contained in:
Adrian Heine 2021-12-20 10:16:39 +01:00
parent 92ac0d0384
commit 52e00de3bb
3 changed files with 6 additions and 6 deletions

View file

@ -14,4 +14,4 @@ tokio = { version = "1.6.1", features = ["rt", "process", "io-util", "macros", "
once_cell = "1.4" once_cell = "1.4"
[dev-dependencies] [dev-dependencies]
tempdir = "0.3" tempfile = "3"

View file

@ -4,10 +4,10 @@ use schematics::symbols::Symbol;
use std::fs::File; use std::fs::File;
use std::io::Write; use std::io::Write;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use tempdir::TempDir; use tempfile::{tempdir, TempDir};
fn get_dir(content: Option<&str>) -> TempDir { fn get_dir(content: Option<&str>) -> TempDir {
let tmp_dir = TempDir::new("unittest").expect("create temp dir"); let tmp_dir = tempdir().expect("create temp dir");
if content.is_none() { if content.is_none() {
return tmp_dir; return tmp_dir;
} }

View file

@ -2,10 +2,10 @@ use regex::Regex;
use schematics::storage::{SimpleStorage, Storage}; use schematics::storage::{SimpleStorage, Storage};
use std::fs::{create_dir, File}; use std::fs::{create_dir, File};
use std::path::Path; use std::path::Path;
use tempdir::TempDir; use tempfile::{tempdir, TempDir};
fn get_dir<'a, I: IntoIterator<Item = &'a &'a str>>(content: I) -> TempDir { fn get_dir<'a, I: IntoIterator<Item = &'a &'a str>>(content: I) -> TempDir {
let tmp_dir = TempDir::new("unittest").expect("create temp dir"); let tmp_dir = tempdir().expect("create temp dir");
let storage_path = tmp_dir.path().join("_filename"); let storage_path = tmp_dir.path().join("_filename");
create_dir(storage_path.clone()).unwrap(); create_dir(storage_path.clone()).unwrap();
for path in content { for path in content {
@ -93,7 +93,7 @@ fn three_files() {
#[test] #[test]
fn empty_storage() { fn empty_storage() {
let dir = TempDir::new("unittest").expect("create temp dir"); let dir = tempdir().expect("create temp dir");
let storage = get_storage(dir.path()); let storage = get_storage(dir.path());
assert!( assert!(