Skip to content

Commit

Permalink
Add test for light formats
Browse files Browse the repository at this point in the history
  • Loading branch information
afelisatti committed Jan 24, 2020
1 parent 6516ec8 commit 50b8f95
Showing 1 changed file with 26 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand All @@ -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")
}
}



}

0 comments on commit 50b8f95

Please sign in to comment.