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

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();