Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
DriesSchaumont committed Dec 30, 2024
1 parent 918d2f5 commit 218bf7f
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: invalid_fromstate_argument
namespace: test_wfs
resources:
- type: nextflow_script
path: main.nf
entrypoint: base
# TODO: make absolute when the ns build uses the right CWD
- path: ../../../resources
dependencies:
- name: sub_workflow
platforms:
- type: nextflow
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
workflow base {
take: input_ch
main:

// generate list from 0 to 1000
ch = Channel.fromList(0..1000)
| map { num ->
// create temporary file
def file = tempFile()
file.write("num: $num")

["num$num", [ file: file ], ["num": num]]
}
| sub_workflow.run(
fromState: [
"file": "file",
"thisargumentdoesnotexist": "file", // this should raise
],
toState: {id, output, state ->
def newState = [
"step1_output": output.output,
"num": state.num,
"file": state.file,
"thisargumentdoesnotexist": "foo"
]
return newState
}
)


emit:
input_ch
}
14 changes: 14 additions & 0 deletions src/test/scala/io/viash/runners/nextflow/NextflowScriptTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,20 @@ class NextflowScriptTest extends AnyFunSuite with BeforeAndAfterAll {
}


test("Test invalid argument in fromState map", DockerTest, NextflowTest) {
val (exitCode, stdOut, stdErr) = NextflowTestHelper.run(
mainScript = "target/nextflow/test_wfs/invalid_fromstate_argument/main.nf",
args = List(
"--publish_dir", "output"
),
cwd = tempFolFile
)

assert(exitCode == 1, s"\nexit code was $exitCode\nStd output:\n$stdOut\nStd error:\n$stdErr")
assert(stdOut.contains("Error processing fromState for 'sub_workflow': invalid argument 'thisargumentdoesnotexist'"))
}


test("Run multiple output channels standalone", NextflowTest) {
val (exitCode, stdOut, stdErr) = NextflowTestHelper.run(
mainScript = "target/nextflow/multiple_emit_channels/main.nf",
Expand Down

0 comments on commit 218bf7f

Please sign in to comment.