Browse Source

Replace tempdir with tempfile

master
Adrian Heine 3 years ago
parent
commit
52e00de3bb
  1. 2
      Cargo.toml
  2. 4
      tests/file.rs
  3. 6
      tests/storage.rs

2
Cargo.toml

@ -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"

4
tests/file.rs

@ -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;
} }

6
tests/storage.rs

@ -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!(

Loading…
Cancel
Save