Skip to content

Commit 9efe6bb

Browse files
add test to confirm unlink/remove behavior
1 parent 62299e4 commit 9efe6bb

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

runtime/src/storage/mod.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ pub(crate) mod tests {
305305
test_read_at_buf_returns_same_buffer(&storage).await;
306306
test_read_at_buf_insufficient_capacity(&storage).await;
307307
test_read_at_buf_larger_capacity(&storage).await;
308+
test_read_after_remove(&storage).await;
308309
}
309310

310311
/// Test opening a blob, writing to it, and reading back the data.
@@ -342,6 +343,28 @@ pub(crate) mod tests {
342343
assert!(blobs.is_empty(), "Blob was not removed as expected");
343344
}
344345

346+
/// Test that existing blob handles remain readable after the blob is removed from storage.
347+
async fn test_read_after_remove<S>(storage: &S)
348+
where
349+
S: Storage + Send + Sync,
350+
S::Blob: Send + Sync,
351+
{
352+
let (blob, _) = storage
353+
.open("read_after_remove", b"blob")
354+
.await
355+
.unwrap();
356+
blob.write_at(0, b"still here").await.unwrap();
357+
blob.sync().await.unwrap();
358+
359+
storage
360+
.remove("read_after_remove", Some(b"blob"))
361+
.await
362+
.unwrap();
363+
364+
let read = blob.read_at(0, 10).await.unwrap();
365+
assert_eq!(read.coalesce(), b"still here");
366+
}
367+
345368
/// Test scanning a partition for blobs.
346369
async fn test_scan<S>(storage: &S)
347370
where

0 commit comments

Comments
 (0)