Skip to content

Commit 13d8a1a

Browse files
committed
add test
1 parent dece396 commit 13d8a1a

3 files changed

Lines changed: 75 additions & 0 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
functionality:
2+
name: integer_as_double
3+
arguments:
4+
- name: "--input"
5+
type: file
6+
required: true
7+
example: input.txt
8+
- name: "--output"
9+
type: file
10+
required: true
11+
direction: output
12+
example: output.txt
13+
- name: "--double"
14+
type: double
15+
required: true
16+
direction: input
17+
example: 10.5
18+
resources:
19+
- type: bash_script
20+
path: script.sh
21+
platforms:
22+
- type: native
23+
- type: docker
24+
image: nextflow/bash:latest
25+
- type: nextflow
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
## VIASH START
4+
par_input='resources/lines3.txt'
5+
par_double='10.5'
6+
par_output='output.txt'
7+
## VIASH END
8+
9+
echo "Copying $par_input to $par_output"
10+
cp "$par_input" "$par_output"
11+
12+
echo "Adding $par_double to $par_output"
13+
echo "Double: $par_double" >> "$par_output"
14+
15+
exit 0

src/test/scala/io/viash/platforms/nextflow/Vdsl3StandaloneTest.scala

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,41 @@ class Vdsl3StandaloneTest extends AnyFunSuite with BeforeAndAfterAll {
211211
}
212212
}
213213

214+
215+
test("Whether integers can be converted to doubles", NextflowTest) {
216+
val (exitCode, stdOut, stdErr) = NextflowTestHelper.run(
217+
mainScript = "target/nextflow/integer_as_double/main.nf",
218+
args = List(
219+
"--id", "foo",
220+
"--input", "resources/lines3.txt",
221+
"--double", "10", // this should be an integer
222+
"--publish_dir", "integerAsDouble"
223+
),
224+
cwd = tempFolFile
225+
)
226+
227+
assert(exitCode == 0, s"\nexit code was $exitCode\nStd output:\n$stdOut\nStd error:\n$stdErr")
228+
229+
val expectedFiles =
230+
Map(
231+
"state" -> "state.yaml",
232+
"output" -> "output.txt",
233+
).map{ case (id, suffix) =>
234+
val path = temporaryFolder.resolve("integerAsDouble/foo.integer_as_double." + suffix)
235+
(id, path)
236+
}
237+
238+
// check if files exist
239+
240+
val src = Source.fromFile(tempFolStr + "/integerAsDouble/foo.integer_as_double.output.txt")
241+
try {
242+
val moduleOut = src.getLines().mkString(",")
243+
assert(moduleOut.equals("one,two,three,Double: 10.0"), s"Expected output 'one,two,three,10.0' but got '$moduleOut'")
244+
} finally {
245+
src.close()
246+
}
247+
}
248+
214249
override def afterAll(): Unit = {
215250
IO.deleteRecursively(temporaryFolder)
216251
}

0 commit comments

Comments
 (0)