Skip to content

Commit 340c315

Browse files
committed
add integration test for javy_plugin_v2
1 parent 3526cf2 commit 340c315

File tree

1 file changed

+32
-25
lines changed

1 file changed

+32
-25
lines changed

tests/integration_tests.rs

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -64,31 +64,6 @@ mod tests {
6464
Ok(())
6565
}
6666

67-
#[test]
68-
fn run_javy_plugin_v2() -> Result<()> {
69-
let mut cmd = Command::cargo_bin("function-runner")?;
70-
71-
let input_file = temp_input(json!({"cart": { "lines" : ["alex"]}}))?;
72-
let file = File::open(input_file.path())?;
73-
74-
let output = cmd
75-
.args([
76-
"--function",
77-
"tests/fixtures/build/js_functions_javy_v2.wasm",
78-
])
79-
.arg("--json")
80-
.stdin(Stdio::from(file))
81-
.stdout(Stdio::piped())
82-
.spawn()
83-
.expect("Failed to spawn child process")
84-
.wait_with_output()
85-
.expect("Failed waiting for output");
86-
87-
output.clone().assert().success();
88-
89-
Ok(())
90-
}
91-
9267
#[test]
9368
fn run_no_opts() -> Result<()> {
9469
let mut cmd = Command::cargo_bin("function-runner")?;
@@ -448,4 +423,36 @@ mod tests {
448423

449424
Ok(())
450425
}
426+
427+
#[test]
428+
fn run_javy_plugin_v2() -> Result<()> {
429+
let mut cmd = Command::cargo_bin("function-runner")?;
430+
let input = temp_input(json!({"hello": "world"}))?;
431+
432+
cmd.args([
433+
"--function",
434+
"tests/fixtures/build/js_function_javy_plugin_v2.wasm",
435+
])
436+
.arg("--json")
437+
.args(["--codec", "messagepack"])
438+
.args(["--export", "run"])
439+
.arg("--input")
440+
.arg(input.as_os_str())
441+
.stdout(Stdio::piped())
442+
.spawn()
443+
.expect("Failed to spawn child process")
444+
.wait_with_output()
445+
.expect("Failed waiting for output");
446+
447+
// Command should succeed
448+
cmd.assert().success();
449+
450+
// Input should be returned
451+
cmd.assert().stdout(contains("hello"));
452+
cmd.assert().stdout(contains("world"));
453+
454+
// Module output should be returned
455+
cmd.assert().stdout(contains("discountApplicationStrategy"));
456+
Ok(())
457+
}
451458
}

0 commit comments

Comments
 (0)