Replace tempfile with tempdir

This commit is contained in:
Dustin J. Mitchell 2021-04-16 19:29:27 -04:00
parent 9c54985fac
commit c8d6619d71
9 changed files with 34 additions and 87 deletions

59
Cargo.lock generated
View file

@ -841,12 +841,6 @@ dependencies = [
"percent-encoding",
]
[[package]]
name = "fuchsia-cprng"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
[[package]]
name = "fuchsia-zircon"
version = "0.3.3"
@ -1702,19 +1696,6 @@ version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "941ba9d78d8e2f7ce474c015eea4d9c6d25b6a3327f9832ee29a4de27f91bbb8"
[[package]]
name = "rand"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293"
dependencies = [
"fuchsia-cprng",
"libc",
"rand_core 0.3.1",
"rdrand",
"winapi 0.3.9",
]
[[package]]
name = "rand"
version = "0.7.3"
@ -1759,21 +1740,6 @@ dependencies = [
"rand_core 0.6.2",
]
[[package]]
name = "rand_core"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
dependencies = [
"rand_core 0.4.2",
]
[[package]]
name = "rand_core"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc"
[[package]]
name = "rand_core"
version = "0.5.1"
@ -1810,15 +1776,6 @@ dependencies = [
"rand_core 0.6.2",
]
[[package]]
name = "rdrand"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"
dependencies = [
"rand_core 0.3.1",
]
[[package]]
name = "redox_syscall"
version = "0.1.57"
@ -2232,7 +2189,7 @@ dependencies = [
"proptest",
"serde",
"serde_json",
"tempdir",
"tempfile",
"thiserror",
"tindercrypt",
"ureq",
@ -2254,7 +2211,7 @@ dependencies = [
"predicates",
"prettytable-rs",
"taskchampion",
"tempdir",
"tempfile",
"termcolor",
"textwrap 0.13.4",
]
@ -2272,20 +2229,10 @@ dependencies = [
"kv",
"log",
"serde",
"tempdir",
"tempfile",
"uuid",
]
[[package]]
name = "tempdir"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8"
dependencies = [
"rand 0.4.6",
"remove_dir_all",
]
[[package]]
name = "tempfile"
version = "3.1.0"

View file

@ -26,4 +26,4 @@ path = "../taskchampion"
[dev-dependencies]
assert_cmd = "^1.0.3"
predicates = "^1.0.7"
tempdir = "^0.3.7"
tempfile = "3"

View file

@ -15,13 +15,13 @@ pub(crate) fn execute<W: WriteColor>(
mod test {
use super::*;
use crate::invocation::test::*;
use tempdir::TempDir;
use tempfile::TempDir;
#[test]
fn test_add() {
let mut w = test_writer();
let mut replica = test_replica();
let server_dir = TempDir::new("test").unwrap();
let server_dir = TempDir::new().unwrap();
let mut server = test_server(&server_dir);
// Note that the details of the actual sync are tested thoroughly in the taskchampion crate

View file

@ -1,6 +1,6 @@
use std::io;
use taskchampion::{storage, Replica, Server, ServerConfig};
use tempdir::TempDir;
use tempfile::TempDir;
pub(super) fn test_replica() -> Replica {
let storage = storage::InMemoryStorage::new();

View file

@ -19,4 +19,4 @@ env_logger = "^0.8.3"
[dev-dependencies]
actix-rt = "^2.2.0"
tempdir = "^0.3.7"
tempfile = "3"

View file

@ -164,11 +164,11 @@ impl<'t> StorageTxn for Txn<'t> {
#[cfg(test)]
mod test {
use super::*;
use tempdir::TempDir;
use tempfile::TempDir;
#[test]
fn test_get_client_empty() -> anyhow::Result<()> {
let tmp_dir = TempDir::new("test")?;
let tmp_dir = TempDir::new()?;
let storage = KvStorage::new(&tmp_dir.path())?;
let mut txn = storage.txn()?;
let maybe_client = txn.get_client(Uuid::new_v4())?;
@ -178,7 +178,7 @@ mod test {
#[test]
fn test_client_storage() -> anyhow::Result<()> {
let tmp_dir = TempDir::new("test")?;
let tmp_dir = TempDir::new()?;
let storage = KvStorage::new(&tmp_dir.path())?;
let mut txn = storage.txn()?;
@ -200,7 +200,7 @@ mod test {
#[test]
fn test_gvbp_empty() -> anyhow::Result<()> {
let tmp_dir = TempDir::new("test")?;
let tmp_dir = TempDir::new()?;
let storage = KvStorage::new(&tmp_dir.path())?;
let mut txn = storage.txn()?;
let maybe_version = txn.get_version_by_parent(Uuid::new_v4(), Uuid::new_v4())?;
@ -210,7 +210,7 @@ mod test {
#[test]
fn test_add_version_and_gvbp() -> anyhow::Result<()> {
let tmp_dir = TempDir::new("test")?;
let tmp_dir = TempDir::new()?;
let storage = KvStorage::new(&tmp_dir.path())?;
let mut txn = storage.txn()?;

View file

@ -25,4 +25,4 @@ tindercrypt = { version = "^0.2.2", default-features = false }
[dev-dependencies]
proptest = "^1.0.0"
tempdir = "^0.3.7"
tempfile = "3"

View file

@ -151,11 +151,11 @@ impl<'t> Server for LocalServer<'t> {
#[cfg(test)]
mod test {
use super::*;
use tempdir::TempDir;
use tempfile::TempDir;
#[test]
fn test_empty() -> anyhow::Result<()> {
let tmp_dir = TempDir::new("test")?;
let tmp_dir = TempDir::new()?;
let mut server = LocalServer::new(&tmp_dir.path())?;
let child_version = server.get_child_version(NO_VERSION_ID)?;
assert_eq!(child_version, GetVersionResult::NoSuchVersion);
@ -164,7 +164,7 @@ mod test {
#[test]
fn test_add_zero_base() -> anyhow::Result<()> {
let tmp_dir = TempDir::new("test")?;
let tmp_dir = TempDir::new()?;
let mut server = LocalServer::new(&tmp_dir.path())?;
let history = b"1234".to_vec();
match server.add_version(NO_VERSION_ID, history.clone())? {
@ -189,7 +189,7 @@ mod test {
#[test]
fn test_add_nonzero_base() -> anyhow::Result<()> {
let tmp_dir = TempDir::new("test")?;
let tmp_dir = TempDir::new()?;
let mut server = LocalServer::new(&tmp_dir.path())?;
let history = b"1234".to_vec();
let parent_version_id = Uuid::new_v4() as VersionId;
@ -217,7 +217,7 @@ mod test {
#[test]
fn test_add_nonzero_base_forbidden() -> anyhow::Result<()> {
let tmp_dir = TempDir::new("test")?;
let tmp_dir = TempDir::new()?;
let mut server = LocalServer::new(&tmp_dir.path())?;
let history = b"1234".to_vec();
let parent_version_id = Uuid::new_v4() as VersionId;

View file

@ -354,11 +354,11 @@ impl<'t> StorageTxn for Txn<'t> {
mod test {
use super::*;
use crate::storage::taskmap_with;
use tempdir::TempDir;
use tempfile::TempDir;
#[test]
fn test_create() -> anyhow::Result<()> {
let tmp_dir = TempDir::new("test")?;
let tmp_dir = TempDir::new()?;
let mut storage = KvStorage::new(&tmp_dir.path())?;
let uuid = Uuid::new_v4();
{
@ -376,7 +376,7 @@ mod test {
#[test]
fn test_create_exists() -> anyhow::Result<()> {
let tmp_dir = TempDir::new("test")?;
let tmp_dir = TempDir::new()?;
let mut storage = KvStorage::new(&tmp_dir.path())?;
let uuid = Uuid::new_v4();
{
@ -394,7 +394,7 @@ mod test {
#[test]
fn test_get_missing() -> anyhow::Result<()> {
let tmp_dir = TempDir::new("test")?;
let tmp_dir = TempDir::new()?;
let mut storage = KvStorage::new(&tmp_dir.path())?;
let uuid = Uuid::new_v4();
{
@ -407,7 +407,7 @@ mod test {
#[test]
fn test_set_task() -> anyhow::Result<()> {
let tmp_dir = TempDir::new("test")?;
let tmp_dir = TempDir::new()?;
let mut storage = KvStorage::new(&tmp_dir.path())?;
let uuid = Uuid::new_v4();
{
@ -428,7 +428,7 @@ mod test {
#[test]
fn test_delete_task_missing() -> anyhow::Result<()> {
let tmp_dir = TempDir::new("test")?;
let tmp_dir = TempDir::new()?;
let mut storage = KvStorage::new(&tmp_dir.path())?;
let uuid = Uuid::new_v4();
{
@ -440,7 +440,7 @@ mod test {
#[test]
fn test_delete_task_exists() -> anyhow::Result<()> {
let tmp_dir = TempDir::new("test")?;
let tmp_dir = TempDir::new()?;
let mut storage = KvStorage::new(&tmp_dir.path())?;
let uuid = Uuid::new_v4();
{
@ -457,7 +457,7 @@ mod test {
#[test]
fn test_all_tasks_empty() -> anyhow::Result<()> {
let tmp_dir = TempDir::new("test")?;
let tmp_dir = TempDir::new()?;
let mut storage = KvStorage::new(&tmp_dir.path())?;
{
let mut txn = storage.txn()?;
@ -469,7 +469,7 @@ mod test {
#[test]
fn test_all_tasks_and_uuids() -> anyhow::Result<()> {
let tmp_dir = TempDir::new("test")?;
let tmp_dir = TempDir::new()?;
let mut storage = KvStorage::new(&tmp_dir.path())?;
let uuid1 = Uuid::new_v4();
let uuid2 = Uuid::new_v4();
@ -523,7 +523,7 @@ mod test {
#[test]
fn test_base_version_default() -> anyhow::Result<()> {
let tmp_dir = TempDir::new("test")?;
let tmp_dir = TempDir::new()?;
let mut storage = KvStorage::new(&tmp_dir.path())?;
{
let mut txn = storage.txn()?;
@ -534,7 +534,7 @@ mod test {
#[test]
fn test_base_version_setting() -> anyhow::Result<()> {
let tmp_dir = TempDir::new("test")?;
let tmp_dir = TempDir::new()?;
let mut storage = KvStorage::new(&tmp_dir.path())?;
let u = Uuid::new_v4();
{
@ -551,7 +551,7 @@ mod test {
#[test]
fn test_operations() -> anyhow::Result<()> {
let tmp_dir = TempDir::new("test")?;
let tmp_dir = TempDir::new()?;
let mut storage = KvStorage::new(&tmp_dir.path())?;
let uuid1 = Uuid::new_v4();
let uuid2 = Uuid::new_v4();
@ -615,7 +615,7 @@ mod test {
#[test]
fn get_working_set_empty() -> anyhow::Result<()> {
let tmp_dir = TempDir::new("test")?;
let tmp_dir = TempDir::new()?;
let mut storage = KvStorage::new(&tmp_dir.path())?;
{
@ -629,7 +629,7 @@ mod test {
#[test]
fn add_to_working_set() -> anyhow::Result<()> {
let tmp_dir = TempDir::new("test")?;
let tmp_dir = TempDir::new()?;
let mut storage = KvStorage::new(&tmp_dir.path())?;
let uuid1 = Uuid::new_v4();
let uuid2 = Uuid::new_v4();
@ -652,7 +652,7 @@ mod test {
#[test]
fn clear_working_set() -> anyhow::Result<()> {
let tmp_dir = TempDir::new("test")?;
let tmp_dir = TempDir::new()?;
let mut storage = KvStorage::new(&tmp_dir.path())?;
let uuid1 = Uuid::new_v4();
let uuid2 = Uuid::new_v4();