Skip to content

Commit

Permalink
refactor: enhance namings in the ancillary module
Browse files Browse the repository at this point in the history
- remove useless `Aggregator` reference in the `AncillaryFileUploader` trait name
- rename ancillary builder unit test to reflect `upload_archive` behavior
  • Loading branch information
dlachaume committed Dec 17, 2024
1 parent 5d040d7 commit ba848e2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions mithril-aggregator/src/artifact_builder/cardano_database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ mod tests {
test_utils::{fake_data, TempDir},
};

use crate::artifact_builder::cardano_database_artifacts::MockAncillaryFileUploaderAggregator;
use crate::artifact_builder::cardano_database_artifacts::MockAncillaryFileUploader;

use super::*;

Expand Down Expand Up @@ -168,7 +168,7 @@ mod tests {
.build();
let expected_total_size = immutable_trio_file_size + ledger_file_size + volatile_file_size;

let mut uploader = MockAncillaryFileUploaderAggregator::new();
let mut uploader = MockAncillaryFileUploader::new();
uploader.expect_upload().return_once(|_| {
Ok(AncillaryLocation::CloudStorage {
uri: "ancillary_location_uri".to_string(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ use crate::{FileUploader, LocalUploader};

#[cfg_attr(test, mockall::automock)]
#[async_trait]
pub trait AncillaryFileUploaderAggregator: Send + Sync {
pub trait AncillaryFileUploader: Send + Sync {
async fn upload(&self, filepath: &Path) -> StdResult<AncillaryLocation>;
}

#[async_trait]
impl AncillaryFileUploaderAggregator for LocalUploader {
impl AncillaryFileUploader for LocalUploader {
async fn upload(&self, filepath: &Path) -> StdResult<AncillaryLocation> {
let uri = FileUploader::upload(self, filepath).await?.into();

Expand All @@ -21,11 +21,11 @@ impl AncillaryFileUploaderAggregator for LocalUploader {
}

pub struct AncillaryArtifactBuilder {
uploaders: Vec<Arc<dyn AncillaryFileUploaderAggregator>>,
uploaders: Vec<Arc<dyn AncillaryFileUploader>>,
}

impl AncillaryArtifactBuilder {
pub fn new(uploaders: Vec<Arc<dyn AncillaryFileUploaderAggregator>>) -> Self {
pub fn new(uploaders: Vec<Arc<dyn AncillaryFileUploader>>) -> Self {
Self { uploaders }
}

Expand Down Expand Up @@ -57,8 +57,8 @@ mod tests {
}

#[tokio::test]
async fn upload_archive_should_return_all_uploaders_cloud_storage_locations() {
let mut first_uploader = MockAncillaryFileUploaderAggregator::new();
async fn upload_archive_should_return_all_uploaders_returned_locations() {
let mut first_uploader = MockAncillaryFileUploader::new();
first_uploader
.expect_upload()
.with(eq(Path::new("archive_path")))
Expand All @@ -69,7 +69,7 @@ mod tests {
})
});

let mut second_uploader = MockAncillaryFileUploaderAggregator::new();
let mut second_uploader = MockAncillaryFileUploader::new();
second_uploader
.expect_upload()
.with(eq(Path::new("archive_path")))
Expand All @@ -80,7 +80,7 @@ mod tests {
})
});

let uploaders: Vec<Arc<dyn AncillaryFileUploaderAggregator>> =
let uploaders: Vec<Arc<dyn AncillaryFileUploader>> =
vec![Arc::new(first_uploader), Arc::new(second_uploader)];

let builder = AncillaryArtifactBuilder::new(uploaders);
Expand Down

0 comments on commit ba848e2

Please sign in to comment.