Skip to content

Commit 566a44c

Browse files
authored
Merge pull request #2760 from lann/tempdir-file
Replace tempdir with tempfile
2 parents 6a8b646 + 3e6708d commit 566a44c

File tree

7 files changed

+22
-90
lines changed

7 files changed

+22
-90
lines changed

Cargo.lock

Lines changed: 14 additions & 66 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/factor-key-value/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ spin-factors-test = { path = "../factors-test" }
1818
tokio = { version = "1", features = ["macros", "rt"] }
1919
spin-factor-key-value-spin = { path = "../factor-key-value-spin" }
2020
spin-factor-key-value-redis = { path = "../factor-key-value-redis" }
21-
tempdir = "0.3"
21+
tempfile = "3.12.0"
2222

2323

2424
[lints]

crates/factor-key-value/tests/factor_test.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ async fn custom_spin_key_value_works() -> anyhow::Result<()> {
101101

102102
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
103103
async fn custom_spin_key_value_works_with_absolute_path() -> anyhow::Result<()> {
104-
let tmp_dir = tempdir::TempDir::new("example")?;
104+
let tmp_dir = tempfile::TempDir::with_prefix("example")?;
105105
let db_path = tmp_dir.path().join("foo/custom.db");
106106
// Check that the db does not exist yet - it will exist by the end of the test
107107
assert!(!db_path.exists());
@@ -132,7 +132,7 @@ async fn custom_spin_key_value_works_with_absolute_path() -> anyhow::Result<()>
132132

133133
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
134134
async fn custom_spin_key_value_works_with_relative_path() -> anyhow::Result<()> {
135-
let tmp_dir = tempdir::TempDir::new("example")?;
135+
let tmp_dir = tempfile::TempDir::with_prefix("example")?;
136136
let db_path = tmp_dir.path().join("custom.db");
137137
// Check that the db does not exist yet - it will exist by the end of the test
138138
assert!(!db_path.exists());
@@ -176,7 +176,7 @@ async fn custom_redis_key_value_works() -> anyhow::Result<()> {
176176

177177
#[tokio::test]
178178
async fn misconfigured_spin_key_value_fails() -> anyhow::Result<()> {
179-
let tmp_dir = tempdir::TempDir::new("example")?;
179+
let tmp_dir = tempfile::TempDir::with_prefix("example")?;
180180
let runtime_config = toml::toml! {
181181
[key_value_store.custom]
182182
type = "spin"
@@ -198,7 +198,7 @@ async fn misconfigured_spin_key_value_fails() -> anyhow::Result<()> {
198198
// TODO(rylev): consider removing this test as it is really only a consequence of
199199
// toml deserialization and not a feature of the key-value store.
200200
async fn multiple_custom_key_value_uses_second_store() -> anyhow::Result<()> {
201-
let tmp_dir = tempdir::TempDir::new("example")?;
201+
let tmp_dir = tempfile::TempDir::with_prefix("example")?;
202202
let db_path = tmp_dir.path().join("custom.db");
203203
// Check that the db does not exist yet - it will exist by the end of the test
204204
assert!(!db_path.exists());

crates/trigger/src/cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ impl<T: Trigger> TriggerAppBuilder<T> {
312312
let use_gpu = true;
313313
let state_dir = match options.state_dir {
314314
// Make sure `--state-dir=""` unsets the state dir
315-
Some(s) if s.trim().is_empty() => None,
315+
Some("") => None,
316316
Some(s) => Some(PathBuf::from(s)),
317317
// Default to `.spin/` in the local app dir
318318
None => options.local_app_dir.map(|d| Path::new(d).join(".spin")),

crates/trigger/src/lib.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,7 @@ pub trait Trigger: Sized + Send {
5353
}
5454

5555
/// Run this trigger.
56-
fn run(
57-
self,
58-
trigger_app: TriggerApp<Self>,
59-
) -> impl Future<Output = anyhow::Result<()>> + Send;
56+
fn run(self, trigger_app: TriggerApp<Self>) -> impl Future<Output = anyhow::Result<()>> + Send;
6057

6158
/// Returns a list of host requirements supported by this trigger specifically.
6259
///

examples/spin-timer/Cargo.lock

Lines changed: 0 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/integration.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -422,11 +422,7 @@ Caused by:
422422
)
423423
};
424424
ensure_success("/hello", 200, "I'm a teapot")?;
425-
ensure_success(
426-
"/hello/wildcards/should/be/handled",
427-
200,
428-
"I'm a teapot",
429-
)?;
425+
ensure_success("/hello/wildcards/should/be/handled", 200, "I'm a teapot")?;
430426
ensure_success("/thisshouldfail", 404, "")?;
431427
ensure_success("/hello/test-placement", 200, "text for test")?;
432428
Ok(())

0 commit comments

Comments
 (0)