From 50b8f9555f27c4834daeae3537c7f93bab0d8e93 Mon Sep 17 00:00:00 2001 From: afelisatti Date: Fri, 24 Jan 2020 17:02:48 -0300 Subject: [PATCH] Add test for light formats --- .../weave/dwnative/cli/DataWeaveCLITest.scala | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/native-cli/src/test/scala/org/mule/weave/dwnative/cli/DataWeaveCLITest.scala b/native-cli/src/test/scala/org/mule/weave/dwnative/cli/DataWeaveCLITest.scala index cea6062..00f9f47 100644 --- a/native-cli/src/test/scala/org/mule/weave/dwnative/cli/DataWeaveCLITest.scala +++ b/native-cli/src/test/scala/org/mule/weave/dwnative/cli/DataWeaveCLITest.scala @@ -11,7 +11,6 @@ import scala.io.Source class DataWeaveCLITest extends FreeSpec with Matchers { - "should work with output application/json" in { val out = System.out try { @@ -41,9 +40,6 @@ class DataWeaveCLITest extends FreeSpec with Matchers { } } - - - "should work ok when sending payload from stdin" in { val out = System.out val in = System.in @@ -70,6 +66,32 @@ class DataWeaveCLITest extends FreeSpec with Matchers { } } + "should work with light formats" in { + val out = System.out + val in = System.in + try { + val input = + """[{ + | "a" : 1, + | "b" : 2, + | "c" : 3 + |}] + """.stripMargin.trim + val stream = new ByteArrayOutputStream() + System.setOut(new PrintStream(stream, true)) + System.setIn(new ByteArrayInputStream(input.getBytes("UTF-8"))) + new DataWeaveCLIRunner().run(Array("input payload json output csv header=false ---payload")) + val source = Source.fromBytes(stream.toByteArray, "UTF-8") + val result = source.mkString.trim + source.close() + result.trim shouldBe "1,2,3" + } finally { + System.setOut(out) + System.setIn(in) + println("Finish OK 2") + } + } + }