Skip to content

Commit

Permalink
Merge pull request #269 from wellsie1116/develop
Browse files Browse the repository at this point in the history
Fixup io::Error not_found conversion
  • Loading branch information
erickt committed Jan 29, 2020
2 parents 212a6ef + d3fbfec commit b82e1ad
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ impl Error {

impl From<io::Error> for Error {
fn from(err: io::Error) -> Error {
Error::Opaque(format!("IO: {:?}", err))
match err.kind() {
std::io::ErrorKind::NotFound => Error::NotFound,
_ => Error::Opaque(format!("IO: {:?}", err)),
}
}
}

Expand Down
25 changes: 25 additions & 0 deletions src/repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,7 @@ where
mod test {
use super::*;
use crate::interchange::Json;
use crate::metadata::{Role, RootMetadata};
use futures_executor::block_on;
use tempfile;

Expand Down Expand Up @@ -1007,6 +1008,30 @@ mod test {
})
}

#[test]
fn file_system_repo_metadata_not_found_error() {
block_on(async {
let temp_dir = tempfile::Builder::new()
.prefix("rust-tuf")
.tempdir()
.unwrap();
let repo = FileSystemRepositoryBuilder::new(temp_dir.path())
.build::<Json>()
.unwrap();

assert_eq!(
repo.fetch_metadata::<RootMetadata>(
&MetadataPath::from_role(&Role::Root),
&MetadataVersion::None,
None,
None
)
.await,
Err(Error::NotFound)
);
})
}

#[test]
fn file_system_repo_targets() {
block_on(async {
Expand Down

0 comments on commit b82e1ad

Please sign in to comment.