From 243c2d00753e268d8ad8aefda5b913fda327f4c0 Mon Sep 17 00:00:00 2001 From: Adam Talbot <12817534+adamrtalbot@users.noreply.github.com> Date: Thu, 18 Apr 2024 17:27:48 +0100 Subject: [PATCH] refactor: rewrite nf-tests to use assertAll and precise naming The nf-tests were a bit untidy and used assert statements where they should have used assertAll statements. --- tests/main.nf.test | 48 +++++++++++-------- tests/main.test_bin_script.test | 8 ++-- tests/main.test_create_file.nf.test | 8 ++-- tests/main.test_create_file.nf.test.snap | 8 +++- tests/main.test_create_folder.nf.test | 8 ++-- tests/main.test_create_folder.nf.test.snap | 8 +++- tests/main.test_ignore_fail.test | 12 +++-- tests/main.test_input.nf.test | 8 ++-- tests/main.test_input.nf.test.snap | 8 +++- tests/main.test_mv_file.nf.test | 8 ++-- tests/main.test_mv_file.nf.test.snap | 8 +++- tests/main.test_mv_folder_contents.nf.test | 8 ++-- .../main.test_mv_folder_contents.nf.test.snap | 8 +++- tests/main.test_pass_file.nf.test | 8 ++-- tests/main.test_pass_file.nf.test.snap | 8 +++- tests/main.test_pass_folder.nf.test | 8 ++-- tests/main.test_pass_folder.nf.test.snap | 8 +++- tests/main.test_publish_file.nf.test | 8 ++-- tests/main.test_publish_file.nf.test.snap | 8 +++- tests/main.test_publish_folder.nf.test | 8 ++-- tests/main.test_publish_folder.nf.test.snap | 8 +++- tests/main.test_stage_remote.test | 8 ++-- tests/main.test_success.nf.test | 12 +++-- tests/main.test_success.nf.test.snap | 8 +++- 24 files changed, 157 insertions(+), 83 deletions(-) diff --git a/tests/main.nf.test b/tests/main.nf.test index 98f5d1c..2d6d957 100644 --- a/tests/main.nf.test +++ b/tests/main.nf.test @@ -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() } + ) } } @@ -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() } + ) } } @@ -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() } + ) } } @@ -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() } + ) } } diff --git a/tests/main.test_bin_script.test b/tests/main.test_bin_script.test index 541384d..6f5dae1 100644 --- a/tests/main.test_bin_script.test +++ b/tests/main.test_bin_script.test @@ -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() } + ) } } diff --git a/tests/main.test_create_file.nf.test b/tests/main.test_create_file.nf.test index 4ec84a9..d937abe 100644 --- a/tests/main.test_create_file.nf.test +++ b/tests/main.test_create_file.nf.test @@ -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() } + ) } } diff --git a/tests/main.test_create_file.nf.test.snap b/tests/main.test_create_file.nf.test.snap index a9e0079..80e1693 100644 --- a/tests/main.test_create_file.nf.test.snap +++ b/tests/main.test_create_file.nf.test.snap @@ -1,5 +1,5 @@ { - "Should run without failures": { + "TEST_CREATE_FILE": { "content": [ { "0": [ @@ -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" } } \ No newline at end of file diff --git a/tests/main.test_create_folder.nf.test b/tests/main.test_create_folder.nf.test index e92031e..4b9456e 100644 --- a/tests/main.test_create_folder.nf.test +++ b/tests/main.test_create_folder.nf.test @@ -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() } + ) } } diff --git a/tests/main.test_create_folder.nf.test.snap b/tests/main.test_create_folder.nf.test.snap index 9342c07..efb35c6 100644 --- a/tests/main.test_create_folder.nf.test.snap +++ b/tests/main.test_create_folder.nf.test.snap @@ -1,5 +1,5 @@ { - "Should run without failures": { + "TEST_CREATE_FOLDER": { "content": [ { "0": [ @@ -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" } } \ No newline at end of file diff --git a/tests/main.test_ignore_fail.test b/tests/main.test_ignore_fail.test index 0927524..c488c54 100644 --- a/tests/main.test_ignore_fail.test +++ b/tests/main.test_ignore_fail.test @@ -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 } + ) } } diff --git a/tests/main.test_input.nf.test b/tests/main.test_input.nf.test index 7701fc8..3a72a0a 100644 --- a/tests/main.test_input.nf.test +++ b/tests/main.test_input.nf.test @@ -4,7 +4,7 @@ nextflow_process { script "main.nf" process "TEST_INPUT" - test("Should run without failures") { + test("TEST_INPUT") { when { process { @@ -15,8 +15,10 @@ nextflow_process { } then { - assert process.success - assert snapshot(process.out).match() + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) } } diff --git a/tests/main.test_input.nf.test.snap b/tests/main.test_input.nf.test.snap index a191682..cae0563 100644 --- a/tests/main.test_input.nf.test.snap +++ b/tests/main.test_input.nf.test.snap @@ -1,5 +1,5 @@ { - "Should run without failures": { + "TEST_INPUT": { "content": [ { "0": [ @@ -7,6 +7,10 @@ ] } ], - "timestamp": "2023-10-04T11:56:21.166077" + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.1" + }, + "timestamp": "2024-04-18T17:19:23.807701" } } \ No newline at end of file diff --git a/tests/main.test_mv_file.nf.test b/tests/main.test_mv_file.nf.test index c6651c1..ca3db2f 100644 --- a/tests/main.test_mv_file.nf.test +++ b/tests/main.test_mv_file.nf.test @@ -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() } + ) } } diff --git a/tests/main.test_mv_file.nf.test.snap b/tests/main.test_mv_file.nf.test.snap index 9229b6a..ef3beec 100644 --- a/tests/main.test_mv_file.nf.test.snap +++ b/tests/main.test_mv_file.nf.test.snap @@ -1,5 +1,5 @@ { - "Should run without failures": { + "TEST_MV_FILE": { "content": [ { "0": [ @@ -7,6 +7,10 @@ ] } ], - "timestamp": "2023-10-04T11:56:19.102784" + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.1" + }, + "timestamp": "2024-04-18T17:19:21.768791" } } \ No newline at end of file diff --git a/tests/main.test_mv_folder_contents.nf.test b/tests/main.test_mv_folder_contents.nf.test index 9a30d5c..681cbd3 100644 --- a/tests/main.test_mv_folder_contents.nf.test +++ b/tests/main.test_mv_folder_contents.nf.test @@ -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() } + ) } } diff --git a/tests/main.test_mv_folder_contents.nf.test.snap b/tests/main.test_mv_folder_contents.nf.test.snap index e518bb9..3d0d1cc 100644 --- a/tests/main.test_mv_folder_contents.nf.test.snap +++ b/tests/main.test_mv_folder_contents.nf.test.snap @@ -1,5 +1,5 @@ { - "Should run without failures": { + "TEST_MV_FOLDER_CONTENTS": { "content": [ { "0": [ @@ -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" } } \ No newline at end of file diff --git a/tests/main.test_pass_file.nf.test b/tests/main.test_pass_file.nf.test index d9226f5..c29dd53 100644 --- a/tests/main.test_pass_file.nf.test +++ b/tests/main.test_pass_file.nf.test @@ -4,7 +4,7 @@ nextflow_process { script "main.nf" process "TEST_PASS_FILE" - test("Should run without failures") { + test("TEST_PASS_FILE") { when { process { @@ -15,8 +15,10 @@ nextflow_process { } then { - assert process.success - assert snapshot(process.out).match() + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) } } diff --git a/tests/main.test_pass_file.nf.test.snap b/tests/main.test_pass_file.nf.test.snap index 27eba1e..a3bae0f 100644 --- a/tests/main.test_pass_file.nf.test.snap +++ b/tests/main.test_pass_file.nf.test.snap @@ -1,5 +1,5 @@ { - "Should run without failures": { + "TEST_PASS_FILE": { "content": [ { "0": [ @@ -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" } } \ No newline at end of file diff --git a/tests/main.test_pass_folder.nf.test b/tests/main.test_pass_folder.nf.test index c3610fb..702056f 100644 --- a/tests/main.test_pass_folder.nf.test +++ b/tests/main.test_pass_folder.nf.test @@ -4,7 +4,7 @@ nextflow_process { script "main.nf" process "TEST_PASS_FOLDER" - test("Should run without failures") { + test("TEST_PASS_FOLDER") { when { process { @@ -19,8 +19,10 @@ nextflow_process { } then { - assert process.success - assert snapshot(process.out).match() + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) } } diff --git a/tests/main.test_pass_folder.nf.test.snap b/tests/main.test_pass_folder.nf.test.snap index b2fc621..6a56ae3 100644 --- a/tests/main.test_pass_folder.nf.test.snap +++ b/tests/main.test_pass_folder.nf.test.snap @@ -1,5 +1,5 @@ { - "Should run without failures": { + "TEST_PASS_FOLDER": { "content": [ { "0": [ @@ -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" } } \ No newline at end of file diff --git a/tests/main.test_publish_file.nf.test b/tests/main.test_publish_file.nf.test index fa53810..8954ce1 100644 --- a/tests/main.test_publish_file.nf.test +++ b/tests/main.test_publish_file.nf.test @@ -4,11 +4,13 @@ nextflow_process { script "main.nf" process "TEST_PUBLISH_FILE" - test("Should run without failures") { + test("TEST_PUBLISH_FILE") { then { - assert process.success - assert snapshot(process.out).match() + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) } } diff --git a/tests/main.test_publish_file.nf.test.snap b/tests/main.test_publish_file.nf.test.snap index 91bd257..316b6ec 100644 --- a/tests/main.test_publish_file.nf.test.snap +++ b/tests/main.test_publish_file.nf.test.snap @@ -1,5 +1,5 @@ { - "Should run without failures": { + "TEST_PUBLISH_FILE": { "content": [ { "0": [ @@ -7,6 +7,10 @@ ] } ], - "timestamp": "2023-10-04T11:56:23.047403" + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.1" + }, + "timestamp": "2024-04-18T17:19:25.923767" } } \ No newline at end of file diff --git a/tests/main.test_publish_folder.nf.test b/tests/main.test_publish_folder.nf.test index 8cf02cf..72eb024 100644 --- a/tests/main.test_publish_folder.nf.test +++ b/tests/main.test_publish_folder.nf.test @@ -4,11 +4,13 @@ nextflow_process { script "main.nf" process "TEST_PUBLISH_FOLDER" - test("Should run without failures") { + test("TEST_PUBLISH_FOLDER") { then { - assert process.success - assert snapshot(process.out).match() + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) } } diff --git a/tests/main.test_publish_folder.nf.test.snap b/tests/main.test_publish_folder.nf.test.snap index ff99057..02e5454 100644 --- a/tests/main.test_publish_folder.nf.test.snap +++ b/tests/main.test_publish_folder.nf.test.snap @@ -1,5 +1,5 @@ { - "Should run without failures": { + "TEST_PUBLISH_FOLDER": { "content": [ { "0": [ @@ -10,6 +10,10 @@ ] } ], - "timestamp": "2023-10-04T11:56:26.981311" + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.1" + }, + "timestamp": "2024-04-18T17:19:30.136869" } } \ No newline at end of file diff --git a/tests/main.test_stage_remote.test b/tests/main.test_stage_remote.test index 219fcc3..f151087 100644 --- a/tests/main.test_stage_remote.test +++ b/tests/main.test_stage_remote.test @@ -4,7 +4,7 @@ nextflow_process { script "main.nf" process "TEST_STAGE_REMOTE" - test("Should run without failures") { + test("TEST_STAGE_REMOTE") { when { @@ -20,8 +20,10 @@ nextflow_process { } then { - assert process.success - assert snapshot(process.out).match() + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) } } diff --git a/tests/main.test_success.nf.test b/tests/main.test_success.nf.test index c35362a..c78481e 100644 --- a/tests/main.test_success.nf.test +++ b/tests/main.test_success.nf.test @@ -4,13 +4,15 @@ nextflow_process { script "main.nf" process "TEST_SUCCESS" - test("Should run without failures") { + test("TEST_SUCCESS") { then { - assert process.success - assert process.exitStatus == 0 - assert process.trace.tasks().size() == 1 - assert snapshot(process).match() + assertAll( + { assert process.success }, + { assert process.exitStatus == 0 }, + { assert process.trace.tasks().size() == 1 }, + { assert snapshot(process).match() } + ) } } diff --git a/tests/main.test_success.nf.test.snap b/tests/main.test_success.nf.test.snap index 610d5f4..5d9f1a8 100644 --- a/tests/main.test_success.nf.test.snap +++ b/tests/main.test_success.nf.test.snap @@ -1,5 +1,5 @@ { - "Should run without failures": { + "TEST_SUCCESS": { "content": [ { "stderr": [ @@ -26,6 +26,10 @@ "success": true } ], - "timestamp": "2023-10-04T12:20:24.512086" + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.1" + }, + "timestamp": "2024-04-18T17:19:40.583688" } } \ No newline at end of file