From c7c66abd85cb78664cbe6cbe97f879a3f1f43828 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Sat, 6 Apr 2024 23:37:10 +0300 Subject: refactor(tvix/castore/blobservice/object_store): drop individual tests 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 --- tvix/castore/src/blobservice/object_store.rs | 60 ++-------------------------- 1 file changed, 3 insertions(+), 57 deletions(-) (limited to 'tvix/castore') 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] -- cgit 1.4.1