Skip to content

Commit

Permalink
Tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
casey committed Sep 2, 2024
1 parent b951faa commit 1d417df
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ pub(crate) enum Error {
},
#[snafu(display("extraneous file not in filepack at `{path}`"))]
ExtraneousFile { path: Utf8PathBuf },
#[snafu(display("filepack `{path}` already exists"))]
FilepackExists { path: Utf8PathBuf },
#[snafu(display("hash mismatch for `{path}`, expected {expected} but got {actual}"))]
HashMismatch {
path: Utf8PathBuf,
expected: Hash,
actual: Hash,
},
#[snafu(display("manifest `{path}` already exists"))]
ManifestAlreadyExists { path: Utf8PathBuf },
#[snafu(display(
"internal error, this may indicate a bug in filepack: `{message}` \
consider filing an issue: https://github.com/casey/filepack/issues/new"
Expand Down
2 changes: 1 addition & 1 deletion src/subcommand/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub(crate) fn run(root: &Utf8Path) -> Result {
.try_exists()
.context(error::Io { path: &destination })?
{
return Err(Error::FilepackExists { path: destination });
return Err(Error::ManifestAlreadyExists { path: destination });
}

let filepack = Filepack { files };
Expand Down
17 changes: 17 additions & 0 deletions tests/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,20 @@ fn backslash_error() {
.stderr("error: path `/` has component containing forward slash\n")
.failure();
}

#[test]
fn manifest_already_exists_error() {
let dir = TempDir::new().unwrap();

dir.child("filepack.json").touch().unwrap();

Command::cargo_bin("filepack")
.unwrap()
.args(["create", "."])
.current_dir(&dir)
.assert()
.stderr(format!(
"error: manifest `.{SEPARATOR}filepack.json` already exists\n"
))
.failure();
}

0 comments on commit 1d417df

Please sign in to comment.