Skip to content

Commit

Permalink
Replace deprecated tempdir with tempfile for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LDeakin committed Sep 25, 2023
1 parent 3e90a6a commit 52d1aae
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion examples/array_write_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn array_write_read() -> Result<(), Box<dyn std::error::Error>> {
};

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

Expand Down
2 changes: 1 addition & 1 deletion examples/rectangular_array_write_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fn rectangular_array_write_read() -> Result<(), Box<dyn std::error::Error>> {
};

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

Expand Down
2 changes: 1 addition & 1 deletion examples/sharded_array_write_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fn sharded_array_write_read() -> Result<(), Box<dyn std::error::Error>> {
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());

Expand Down
6 changes: 3 additions & 3 deletions src/storage/store/filesystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ mod tests {

#[test]
fn filesystem_set() -> Result<(), Box<dyn Error>> {
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])?;
Expand All @@ -409,7 +409,7 @@ mod tests {

#[test]
fn filesystem_list() -> Result<(), Box<dyn Error>> {
let path = tempdir::TempDir::new("")?;
let path = tempfile::TempDir::new()?;
let store = FilesystemStore::new(path.path())?;

store.set(&"a/b".try_into()?, &[])?;
Expand Down Expand Up @@ -445,7 +445,7 @@ mod tests {

#[test]
fn filesystem_list_dir() -> Result<(), Box<dyn Error>> {
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()?, &[])?;
Expand Down
14 changes: 7 additions & 7 deletions tests/round_trips.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fn array_metadata_round_trip_memory() -> Result<(), Box<dyn Error>> {
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)?;
Expand All @@ -43,7 +43,7 @@ fn group_metadata_round_trip_memory() -> Result<(), Box<dyn Error>> {
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)?;
Expand All @@ -65,7 +65,7 @@ fn metadata_round_trip_memory() -> Result<(), Box<dyn Error>> {

#[test]
fn metadata_round_trip_filesystem() -> Result<(), Box<dyn Error>> {
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)?;
Expand Down Expand Up @@ -95,7 +95,7 @@ fn filesystem_chunk_round_trip_impl(

#[test]
fn chunk_round_trip_filesystem_key_encoding_default_slash() -> Result<(), Box<dyn Error>> {
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();
Expand All @@ -106,7 +106,7 @@ fn chunk_round_trip_filesystem_key_encoding_default_slash() -> Result<(), Box<dy

#[test]
fn chunk_round_trip_filesystem_key_encoding_default_dot() -> Result<(), Box<dyn Error>> {
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();
Expand All @@ -117,7 +117,7 @@ fn chunk_round_trip_filesystem_key_encoding_default_dot() -> Result<(), Box<dyn

#[test]
fn chunk_round_trip_filesystem_key_encoding_v2_dot() -> Result<(), Box<dyn Error>> {
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();
Expand All @@ -128,7 +128,7 @@ fn chunk_round_trip_filesystem_key_encoding_v2_dot() -> Result<(), Box<dyn Error

#[test]
fn chunk_round_trip_filesystem_key_encoding_v2_slash() -> Result<(), Box<dyn Error>> {
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();
Expand Down

0 comments on commit 52d1aae

Please sign in to comment.