Skip to content

Commit

Permalink
add missing manifest cases
Browse files Browse the repository at this point in the history
  • Loading branch information
aumetra committed May 2, 2024
1 parent a260562 commit 05164df
Showing 1 changed file with 51 additions and 3 deletions.
54 changes: 51 additions & 3 deletions lib/mrf-tool/tests/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ fn read() {
assert_eq!(sink, pretty_manifest);

let mut fs = DummyFs::default();
fs.insert("module.wasm".into(), module_with_manifest.clone());
fs.insert("module.wasm".into(), module_with_manifest);

let mut sink = Vec::new();
mrf_tool::handle(
Expand All @@ -86,6 +86,25 @@ fn read() {
assert_eq!(sink, pretty_manifest);
}

#[test]
fn read_errors() {
let empty_module = empty_module();

let error = mrf_tool::read_manifest(&mut io::sink(), &empty_module).unwrap_err();
assert_eq!(error.to_string(), "missing manifest in module");

let mut fs = DummyFs::default();
fs.insert("empty.wasm".into(), empty_module);

let error = mrf_tool::handle(
&mut fs,
&mut io::sink(),
["mrf-tool", "manifest", "read", "empty.wasm"],
)
.unwrap_err();
assert_eq!(error.to_string(), "missing manifest in module");
}

#[test]
fn remove() {
let empty = empty_module();
Expand All @@ -96,8 +115,8 @@ fn remove() {

mrf_tool::remove_manifest(
&mut fs,
Path::new("module.wasm"),
Path::new("module.removed.wasm"),
"module.wasm".as_ref(),
"module.removed.wasm".as_ref(),
)
.unwrap();
assert_eq!(*fs.get(Path::new("module.removed.wasm")).unwrap(), empty);
Expand All @@ -119,3 +138,32 @@ fn remove() {
.unwrap();
assert_eq!(*fs.get(Path::new("module.removed.wasm")).unwrap(), empty);
}

#[test]
fn remove_errors() {
let mut fs = DummyFs::default();
fs.insert("empty.wasm".into(), empty_module());

let error = mrf_tool::remove_manifest(
&mut fs,
"empty.wasm".as_ref(),
"empty.removed.wasm".as_ref(),
)
.unwrap_err();
assert_eq!(error.to_string(), "missing manifest in module");

let error = mrf_tool::handle(
&mut fs,
&mut io::sink(),
[
"mrf-tool",
"manifest",
"remove",
"empty.wasm",
"--output",
"empty.removed.wasm",
],
)
.unwrap_err();
assert_eq!(error.to_string(), "missing manifest in module");
}

0 comments on commit 05164df

Please sign in to comment.