Skip to content

Commit 3e282f5

Browse files
committed
Add another test case
1 parent 46a7cb4 commit 3e282f5

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

tests/src/test/scala/runtime/actionContainers/ActionLoopRustBasicTests.scala

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class ActionLoopRustBasicTests extends BasicActionRunnerTests with WskActorSyste
138138
|}
139139
""".stripMargin)
140140

141-
it should "support array result" in {
141+
it should "support return array result" in {
142142
val (out, err) = withActionLoopContainer { c =>
143143
val code = """
144144
|extern crate serde_json;
@@ -162,4 +162,33 @@ class ActionLoopRustBasicTests extends BasicActionRunnerTests with WskActorSyste
162162
runRes shouldBe Some(JsArray(JsString("a"), JsString("b")))
163163
}
164164
}
165+
166+
it should "support array as input param" in {
167+
val (out, err) = withActionLoopContainer { c =>
168+
val code = """
169+
|extern crate serde_json;
170+
|
171+
|use serde_derive::{Deserialize, Serialize};
172+
|use serde_json::{Error, Value};
173+
|
174+
|
175+
|pub fn main(args: Value) -> Result<Value, Error> {
176+
| let inputParam = args.as_array();
177+
| let defaultOutput = ["c", "d"];
178+
| match inputParam {
179+
| None => serde_json::to_value(defaultOutput),
180+
| Some(x) => serde_json::to_value(x),
181+
| }
182+
|}
183+
""".stripMargin
184+
185+
val (initCode, _) = c.init(initPayload(code))
186+
187+
initCode should be(200)
188+
189+
val (runCode, runRes) = c.runForJsArray(runPayload(JsArray(JsString("a"), JsString("b"))))
190+
runCode should be(200)
191+
runRes shouldBe Some(JsArray(JsString("a"), JsString("b")))
192+
}
193+
}
165194
}

0 commit comments

Comments
 (0)