Skip to content

Commit

Permalink
Fix Deserialisation of dependencies (#24)
Browse files Browse the repository at this point in the history
* Fix Deserialization of dependencies
  • Loading branch information
mbedulli authored May 31, 2022
1 parent c7958fb commit 7bc0211
Show file tree
Hide file tree
Showing 7 changed files with 723 additions and 336 deletions.
149 changes: 135 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ test-log = "0.2.10"

[dev-dependencies]
project-root = "0.2.2"

mockall = "0.11.1"
12 changes: 8 additions & 4 deletions src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ use crate::{
cache::CacheError::AuthFailure,
cli::HttpGitAuth,
model::protofetch::{Coordinate, Protocol},
proto_repository::ProtoRepository,
proto_repository::ProtoGitRepository,
};

use crate::proto_repository::ProtoRepository;
#[cfg(test)] use mockall::{predicate::*, *};

#[cfg_attr(test, automock)]
pub trait RepositoryCache {
fn clone_or_update(&self, entry: &Coordinate) -> Result<ProtoRepository, CacheError>;
fn clone_or_update(&self, entry: &Coordinate) -> Result<Box<dyn ProtoRepository>, CacheError>;
}

pub struct ProtofetchGitCache {
Expand All @@ -32,7 +36,7 @@ pub enum CacheError {
}

impl RepositoryCache for ProtofetchGitCache {
fn clone_or_update(&self, entry: &Coordinate) -> Result<ProtoRepository, CacheError> {
fn clone_or_update(&self, entry: &Coordinate) -> Result<Box<dyn ProtoRepository>, CacheError> {
let repo = match self.get_entry(entry) {
None => self.clone_repo(entry)?,
Some(path) => {
Expand All @@ -44,7 +48,7 @@ impl RepositoryCache for ProtofetchGitCache {
}
};

Ok(ProtoRepository::new(repo))
Ok(Box::new(ProtoGitRepository::new(repo)))
}
}

Expand Down
Loading

0 comments on commit 7bc0211

Please sign in to comment.