From 52d1aaed6ed9b0c842bccb2e1612a393131e23b4 Mon Sep 17 00:00:00 2001 From: Lachlan Deakin Date: Tue, 26 Sep 2023 09:13:56 +1000 Subject: [PATCH] Replace deprecated tempdir with tempfile for tests --- CHANGELOG.md | 1 + Cargo.toml | 2 +- examples/array_write_read.rs | 2 +- examples/rectangular_array_write_read.rs | 2 +- examples/sharded_array_write_read.rs | 2 +- src/storage/store/filesystem.rs | 6 +++--- tests/round_trips.rs | 14 +++++++------- 7 files changed, 15 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aedc8259..b251f3f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Require the `ndarray` *feature* for examples - Remove the `ndarray` dev dependency - Remove the `ndarray` dependency for the `sharding` feature + - Replace deprecated `tempdir` with `tempfile` for tests ## [0.2.0] - 2023-09-25 diff --git a/Cargo.toml b/Cargo.toml index 87d264ad..db2ef94e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,4 +51,4 @@ walkdir = "2.3.3" zstd = { version = "0.12.4", optional = true } [dev-dependencies] -tempdir = "0.3.7" +tempfile = "3.8.0" diff --git a/examples/array_write_read.rs b/examples/array_write_read.rs index c4856282..59bb44f8 100644 --- a/examples/array_write_read.rs +++ b/examples/array_write_read.rs @@ -10,7 +10,7 @@ fn array_write_read() -> Result<(), Box> { }; // Create a store - // let path = tempdir::TempDir::new("example")?; + // let path = tempfile::TempDir::new()?; // let store = Arc::new(store::filesystem::FilesystemStore::new(path.path())?); let store = std::sync::Arc::new(store::MemoryStore::default()); diff --git a/examples/rectangular_array_write_read.rs b/examples/rectangular_array_write_read.rs index 6a2baf29..0ca50530 100644 --- a/examples/rectangular_array_write_read.rs +++ b/examples/rectangular_array_write_read.rs @@ -8,7 +8,7 @@ fn rectangular_array_write_read() -> Result<(), Box> { }; // Create a store - // let path = tempdir::TempDir::new("example")?; + // let path = tempfile::TempDir::new()?; // let store = Arc::new(store::filesystem::FilesystemStore::new(path.path())?); let store = std::sync::Arc::new(store::MemoryStore::default()); diff --git a/examples/sharded_array_write_read.rs b/examples/sharded_array_write_read.rs index b763b94d..12112275 100644 --- a/examples/sharded_array_write_read.rs +++ b/examples/sharded_array_write_read.rs @@ -14,7 +14,7 @@ fn sharded_array_write_read() -> Result<(), Box> { use std::sync::Arc; // Create a store - // let path = tempdir::TempDir::new("example")?; + // let path = tempfile::TempDir::new()?; // let store = Arc::new(store::filesystem::FilesystemStore::new(path.path())?); let store = Arc::new(store::MemoryStore::default()); diff --git a/src/storage/store/filesystem.rs b/src/storage/store/filesystem.rs index ae5c69fe..a512751f 100644 --- a/src/storage/store/filesystem.rs +++ b/src/storage/store/filesystem.rs @@ -397,7 +397,7 @@ mod tests { #[test] fn filesystem_set() -> Result<(), Box> { - let path = tempdir::TempDir::new("")?; + let path = tempfile::TempDir::new()?; let store = FilesystemStore::new(path.path())?; let key = "a/b".try_into()?; store.set(&key, &[0, 1, 2])?; @@ -409,7 +409,7 @@ mod tests { #[test] fn filesystem_list() -> Result<(), Box> { - let path = tempdir::TempDir::new("")?; + let path = tempfile::TempDir::new()?; let store = FilesystemStore::new(path.path())?; store.set(&"a/b".try_into()?, &[])?; @@ -445,7 +445,7 @@ mod tests { #[test] fn filesystem_list_dir() -> Result<(), Box> { - let path = tempdir::TempDir::new("")?; + let path = tempfile::TempDir::new()?; let store = FilesystemStore::new(path.path())?.sorted(); store.set(&"a/b".try_into()?, &[])?; store.set(&"a/c".try_into()?, &[])?; diff --git a/tests/round_trips.rs b/tests/round_trips.rs index c9dc9c4f..5bd52ccf 100644 --- a/tests/round_trips.rs +++ b/tests/round_trips.rs @@ -26,7 +26,7 @@ fn array_metadata_round_trip_memory() -> Result<(), Box> { let array: ArrayMetadata = serde_json::from_value(json.clone())?; println!("{array:#?}"); - let path = tempdir::TempDir::new("")?; + let path = tempfile::TempDir::new()?; let store = FilesystemStore::new(path.path())?; create_array(&store, &"/array".try_into()?, &array)?; @@ -43,7 +43,7 @@ fn group_metadata_round_trip_memory() -> Result<(), Box> { let group: GroupMetadata = serde_json::from_value(json.clone())?; println!("{group:#?}"); - let path = tempdir::TempDir::new("")?; + let path = tempfile::TempDir::new()?; let store = FilesystemStore::new(path.path())?; create_group(&store, &"/group".try_into()?, &group)?; @@ -65,7 +65,7 @@ fn metadata_round_trip_memory() -> Result<(), Box> { #[test] fn metadata_round_trip_filesystem() -> Result<(), Box> { - let path = tempdir::TempDir::new("")?; + let path = tempfile::TempDir::new()?; let store = FilesystemStore::new(path.path())?; let metadata_in = include_bytes!("data/array_metadata.json"); store.set(&meta_key(&"/group/array".try_into()?), metadata_in)?; @@ -95,7 +95,7 @@ fn filesystem_chunk_round_trip_impl( #[test] fn chunk_round_trip_filesystem_key_encoding_default_slash() -> Result<(), Box> { - let path = tempdir::TempDir::new("")?; + let path = tempfile::TempDir::new()?; let chunk_key_encoding: ChunkKeyEncoding = Box::new(DefaultChunkKeyEncoding::default()); filesystem_chunk_round_trip_impl(path.path(), &chunk_key_encoding)?; let mut path_expect = path.path().to_owned(); @@ -106,7 +106,7 @@ fn chunk_round_trip_filesystem_key_encoding_default_slash() -> Result<(), Box Result<(), Box> { - let path = tempdir::TempDir::new("")?; + let path = tempfile::TempDir::new()?; let chunk_key_encoding: ChunkKeyEncoding = Box::new(DefaultChunkKeyEncoding::new_dot()); filesystem_chunk_round_trip_impl(path.path(), &chunk_key_encoding)?; let mut path_expect = path.path().to_owned(); @@ -117,7 +117,7 @@ fn chunk_round_trip_filesystem_key_encoding_default_dot() -> Result<(), Box Result<(), Box> { - let path = tempdir::TempDir::new("")?; + let path = tempfile::TempDir::new()?; let chunk_key_encoding: ChunkKeyEncoding = Box::new(V2ChunkKeyEncoding::default()); filesystem_chunk_round_trip_impl(path.path(), &chunk_key_encoding)?; let mut path_expect = path.path().to_owned(); @@ -128,7 +128,7 @@ fn chunk_round_trip_filesystem_key_encoding_v2_dot() -> Result<(), Box Result<(), Box> { - let path = tempdir::TempDir::new("")?; + let path = tempfile::TempDir::new()?; let chunk_key_encoding: ChunkKeyEncoding = Box::new(V2ChunkKeyEncoding::new_slash()); filesystem_chunk_round_trip_impl(path.path(), &chunk_key_encoding)?; let mut path_expect = path.path().to_owned();