diff options
author | Florian Klink <flokli@flokli.de> | 2024-04-06T20·37+0300 |
---|---|---|
committer | flokli <flokli@flokli.de> | 2024-04-07T14·51+0000 |
commit | c7c66abd85cb78664cbe6cbe97f879a3f1f43828 (patch) | |
tree | 2c4e3b6db71e4f182f78bcabfea3479968faa84a | |
parent | 32ac9bd110837fdaad11855381756f9cdb1f0ba7 (diff) |
refactor(tvix/castore/blobservice/object_store): drop individual tests r/7861
This (and more) should now be covered by the generic testsuite (in crate::blobservice::tests). Change-Id: Ib3afc4f19f7e37a561b7398d43663dc941971f5c Reviewed-on: https://cl.tvl.fyi/c/depot/+/11365 Tested-by: BuildkiteCI Reviewed-by: picnoir picnoir <picnoir@alternativebit.fr>
-rw-r--r-- | tvix/castore/src/blobservice/object_store.rs | 60 |
1 files changed, 3 insertions, 57 deletions
diff --git a/tvix/castore/src/blobservice/object_store.rs b/tvix/castore/src/blobservice/object_store.rs index 0dba19ef54bb..106c3d5169aa 100644 --- a/tvix/castore/src/blobservice/object_store.rs +++ b/tvix/castore/src/blobservice/object_store.rs @@ -471,67 +471,13 @@ where #[cfg(test)] mod test { - use std::{io::Cursor, sync::Arc}; - - use test_case::test_case; - use url::Url; - use super::chunk_and_upload; use crate::{ blobservice::{BlobService, ObjectStoreBlobService}, - fixtures::{BLOB_A, BLOB_A_DIGEST, BLOB_B, BLOB_B_DIGEST, EMPTY_BLOB_DIGEST}, - B3Digest, + fixtures::{BLOB_A, BLOB_A_DIGEST}, }; - - #[test_case(&BLOB_A, &BLOB_A_DIGEST; "blob a")] - #[test_case(&BLOB_B, &BLOB_B_DIGEST; "blob b")] - #[test_case(&[], &EMPTY_BLOB_DIGEST; "empty blob")] - #[tokio::test] - async fn upload_blob(fix_blob_contents: &[u8], fix_blob_digest: &B3Digest) { - let blobsvc = - ObjectStoreBlobService::parse_url(&Url::parse("memory:///").unwrap()).unwrap(); - - // Initially, the blob should not be present - assert!(!blobsvc.has(fix_blob_digest).await.unwrap()); - - // Using the open_read should return a Ok(None). - // As for the empty blob, we're ok with it actually returning data too. - { - let resp = blobsvc - .open_read(fix_blob_digest) - .await - .expect("open should not fail"); - if fix_blob_digest != &*EMPTY_BLOB_DIGEST { - assert!(resp.is_none()); - } - } - - // upload blob - let mut bw = blobsvc.open_write().await; - tokio::io::copy(&mut Cursor::new(fix_blob_contents), &mut bw) - .await - .expect("copy succeeds"); - - let blob_digest = bw.close().await.expect("close succeeds"); - assert_eq!(fix_blob_digest, &blob_digest); - - // blob should be present now - assert!(blobsvc.has(fix_blob_digest).await.unwrap()); - - // reading it should return the same data. - let mut br = blobsvc - .open_read(fix_blob_digest) - .await - .expect("open succeeds") - .expect("is some"); - - let mut buf = Vec::new(); - tokio::io::copy(&mut br, &mut buf) - .await - .expect("copy must succeed"); - - assert_eq!(fix_blob_contents, buf, "read data should match"); - } + use std::{io::Cursor, sync::Arc}; + use url::Url; /// Tests chunk_and_upload directly, bypassing the BlobWriter at open_write(). #[tokio::test] |