Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: rewrite nf-tests to use assertAll and precise naming #26

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 28 additions & 20 deletions tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ nextflow_pipeline{
}

then {
assert workflow.success
assert workflow.trace.tasks().size() == 14
assert workflow.trace.succeeded().size() == 13
assert workflow.trace.failed().size() == 1
assert snapshot(workflow, path(params.outdir).list()).match()
assertAll(
{ assert workflow.success },
{ assert workflow.trace.tasks().size() == 14 },
{ assert workflow.trace.succeeded().size() == 13 },
{ assert workflow.trace.failed().size() == 1 },
{ assert snapshot(workflow, path(params.outdir).list()).match() }
)
}

}
Expand All @@ -33,11 +35,13 @@ nextflow_pipeline{
}

then {
assert workflow.success
assert workflow.trace.tasks().size() == 13
assert workflow.trace.succeeded().size() == 12
assert workflow.trace.failed().size() == 1
assert snapshot(workflow, path(params.outdir).list()).match()
assertAll(
{ assert workflow.success },
{ assert workflow.trace.tasks().size() == 13 },
{ assert workflow.trace.succeeded().size() == 12 },
{ assert workflow.trace.failed().size() == 1 },
{ assert snapshot(workflow, path(params.outdir).list()).match() }
)
}

}
Expand All @@ -54,11 +58,13 @@ nextflow_pipeline{
}

then {
assert workflow.success
assert workflow.trace.tasks().size() == 1
assert workflow.trace.succeeded().size() == 1
assert workflow.trace.failed().size() == 0
assert snapshot(workflow, path(params.outdir).list()).match()
assertAll(
{ assert workflow.success },
{ assert workflow.trace.tasks().size() == 1 },
{ assert workflow.trace.succeeded().size() == 1 },
{ assert workflow.trace.failed().size() == 0 },
{ assert snapshot(workflow, path(params.outdir).list()).match() }
)
}

}
Expand All @@ -73,11 +79,13 @@ nextflow_pipeline{
}

then {
assert workflow.success
assert workflow.trace.tasks().size() == 14
assert workflow.trace.succeeded().size() == 13
assert workflow.trace.failed().size() == 1
assert snapshot(workflow, path("${launchDir}/output").list()).match()
assertAll(
{ assert workflow.success },
{ assert workflow.trace.tasks().size() == 14 },
{ assert workflow.trace.succeeded().size() == 13 },
{ assert workflow.trace.failed().size() == 1 },
{ assert snapshot(workflow, path("${launchDir}/output").list()).match() }
)
}

}
Expand Down
8 changes: 5 additions & 3 deletions tests/main.test_bin_script.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ nextflow_process {
script "main.nf"
process "TEST_BIN_SCRIPT"

test("Should run without failures") {
test("TEST_BIN_SCRIPT") {

then {
assert process.success
assert snapshot(process.out).match()
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}

}
Expand Down
8 changes: 5 additions & 3 deletions tests/main.test_create_file.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ nextflow_process {
script "main.nf"
process "TEST_CREATE_FILE"

test("Should run without failures") {
test("TEST_CREATE_FILE") {

then {
assert process.success
assert snapshot(process.out).match()
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}

}
Expand Down
8 changes: 6 additions & 2 deletions tests/main.test_create_file.nf.test.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"Should run without failures": {
"TEST_CREATE_FILE": {
"content": [
{
"0": [
Expand All @@ -10,6 +10,10 @@
]
}
],
"timestamp": "2023-10-04T11:56:41.550158"
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
},
"timestamp": "2024-04-18T17:19:44.512229"
}
}
8 changes: 5 additions & 3 deletions tests/main.test_create_folder.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ nextflow_process {
script "main.nf"
process "TEST_CREATE_FOLDER"

test("Should run without failures") {
test("TEST_CREATE_FOLDER") {

then {
assert process.success
assert snapshot(process.out).match()
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}

}
Expand Down
8 changes: 6 additions & 2 deletions tests/main.test_create_folder.nf.test.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"Should run without failures": {
"TEST_CREATE_FOLDER": {
"content": [
{
"0": [
Expand All @@ -16,6 +16,10 @@
]
}
],
"timestamp": "2023-10-04T11:56:39.696681"
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
},
"timestamp": "2024-04-18T17:19:42.631931"
}
}
12 changes: 7 additions & 5 deletions tests/main.test_ignore_fail.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ nextflow_process {
script "main.nf"
process "TEST_IGNORED_FAIL"

test("Should run without failures") {
test("TEST_IGNORED_FAIL") {

then {
assert process.success
assert snapshot(process).match()
assert process.trace.failed().size() == 1
assert process.trace.succeeded().size() == 0
assertAll(
{ assert process.success },
{ assert snapshot(process).match() },
{ assert process.trace.failed().size() == 1 },
{ assert process.trace.succeeded().size() == 0 }
)
}

}
Expand Down
8 changes: 5 additions & 3 deletions tests/main.test_input.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ nextflow_process {
script "main.nf"
process "TEST_INPUT"

test("Should run without failures") {
test("TEST_INPUT") {

when {
process {
Expand All @@ -15,8 +15,10 @@ nextflow_process {
}

then {
assert process.success
assert snapshot(process.out).match()
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}

}
Expand Down
8 changes: 6 additions & 2 deletions tests/main.test_input.nf.test.snap
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
{
"Should run without failures": {
"TEST_INPUT": {
"content": [
{
"0": [
"alpha\n"
]
}
],
"timestamp": "2023-10-04T11:56:21.166077"
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
},
"timestamp": "2024-04-18T17:19:23.807701"
}
}
8 changes: 5 additions & 3 deletions tests/main.test_mv_file.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ nextflow_process {
script "main.nf"
process "TEST_MV_FILE"

test("Should run without failures") {
test("TEST_MV_FILE") {

then {
assert process.success
assert snapshot(process.out).match()
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}

}
Expand Down
8 changes: 6 additions & 2 deletions tests/main.test_mv_file.nf.test.snap
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
{
"Should run without failures": {
"TEST_MV_FILE": {
"content": [
{
"0": [
"output.txt:md5,d41d8cd98f00b204e9800998ecf8427e"
]
}
],
"timestamp": "2023-10-04T11:56:19.102784"
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
},
"timestamp": "2024-04-18T17:19:21.768791"
}
}
8 changes: 5 additions & 3 deletions tests/main.test_mv_folder_contents.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ nextflow_process {
script "main.nf"
process "TEST_MV_FOLDER_CONTENTS"

test("Should run without failures") {
test("TEST_MV_FOLDER_CONTENTS") {

then {
assert process.success
assert snapshot(process.out).match()
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}

}
Expand Down
8 changes: 6 additions & 2 deletions tests/main.test_mv_folder_contents.nf.test.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"Should run without failures": {
"TEST_MV_FOLDER_CONTENTS": {
"content": [
{
"0": [
Expand All @@ -14,6 +14,10 @@
]
}
],
"timestamp": "2023-10-04T12:19:57.98459"
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
},
"timestamp": "2024-04-18T17:19:19.746587"
}
}
8 changes: 5 additions & 3 deletions tests/main.test_pass_file.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ nextflow_process {
script "main.nf"
process "TEST_PASS_FILE"

test("Should run without failures") {
test("TEST_PASS_FILE") {

when {
process {
Expand All @@ -15,8 +15,10 @@ nextflow_process {
}

then {
assert process.success
assert snapshot(process.out).match()
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}

}
Expand Down
8 changes: 6 additions & 2 deletions tests/main.test_pass_file.nf.test.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"Should run without failures": {
"TEST_PASS_FILE": {
"content": [
{
"0": [
Expand All @@ -10,6 +10,10 @@
]
}
],
"timestamp": "2023-10-04T11:56:24.966198"
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
},
"timestamp": "2024-04-18T17:19:28.094518"
}
}
8 changes: 5 additions & 3 deletions tests/main.test_pass_folder.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ nextflow_process {
script "main.nf"
process "TEST_PASS_FOLDER"

test("Should run without failures") {
test("TEST_PASS_FOLDER") {

when {
process {
Expand All @@ -19,8 +19,10 @@ nextflow_process {
}

then {
assert process.success
assert snapshot(process.out).match()
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}

}
Expand Down
8 changes: 6 additions & 2 deletions tests/main.test_pass_folder.nf.test.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"Should run without failures": {
"TEST_PASS_FOLDER": {
"content": [
{
"0": [
Expand All @@ -14,6 +14,10 @@
]
}
],
"timestamp": "2023-10-04T12:19:55.945452"
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
},
"timestamp": "2024-04-18T17:19:17.775111"
}
}
Loading
Loading