From 7dee4476669957b3b53cd3e77dd7cdbc7b544a1a Mon Sep 17 00:00:00 2001 From: Nicolas Vannieuwkerke Date: Mon, 26 Aug 2024 17:33:20 +0200 Subject: [PATCH] fix linting utils_nfschema_plugin --- .../nf-core/utils_nfschema_plugin/meta.yml | 13 ++++ .../utils_nfschema_plugin/tests/main.nf.test | 63 +++++++++++++++++-- 2 files changed, 72 insertions(+), 4 deletions(-) diff --git a/nf_core/pipeline-template/subworkflows/nf-core/utils_nfschema_plugin/meta.yml b/nf_core/pipeline-template/subworkflows/nf-core/utils_nfschema_plugin/meta.yml index 90b8cb189..f7d9f0288 100644 --- a/nf_core/pipeline-template/subworkflows/nf-core/utils_nfschema_plugin/meta.yml +++ b/nf_core/pipeline-template/subworkflows/nf-core/utils_nfschema_plugin/meta.yml @@ -9,9 +9,22 @@ keywords: - summary components: [] input: + - input_workflow: + type: object + description: | + The workflow object of the used pipeline. + This object contains meta data used to create the params summary log - validate_params: type: boolean description: Validate the parameters and error if invalid. + - parameters_schema: + type: string + description: | + Path to the parameters JSON schema. + This has to be the same as the schema given to the `validation.parametersSchema` config + option. When this input is empty it will automatically use the configured schema or + "${projectDir}/nextflow_schema.json" as default. The schema should not be given in this way + for meta pipelines. output: - dummy_emit: type: boolean diff --git a/nf_core/pipeline-template/subworkflows/nf-core/utils_nfschema_plugin/tests/main.nf.test b/nf_core/pipeline-template/subworkflows/nf-core/utils_nfschema_plugin/tests/main.nf.test index 703d3a9b8..842dc432a 100644 --- a/nf_core/pipeline-template/subworkflows/nf-core/utils_nfschema_plugin/tests/main.nf.test +++ b/nf_core/pipeline-template/subworkflows/nf-core/utils_nfschema_plugin/tests/main.nf.test @@ -1,5 +1,3 @@ -// TODO nf-core: Once you have added the required tests, please run the following command to build this file: -// nf-core subworkflows test utils_nfschema_plugin nextflow_workflow { name "Test Subworkflow UTILS_NFSCHEMA_PLUGIN" @@ -9,6 +7,7 @@ nextflow_workflow { tag "subworkflows" tag "subworkflows_nfcore" tag "subworkflows/utils_nfschema_plugin" + tag "plugin/nf-schema" config "./nextflow.config" @@ -23,7 +22,9 @@ nextflow_workflow { workflow { """ validate_params = false - input[0] = validate_params + input[0] = workflow + input[1] = validate_params + input[2] = "" """ } } @@ -47,7 +48,61 @@ nextflow_workflow { workflow { """ validate_params = true - input[0] = validate_params + input[0] = workflow + input[1] = validate_params + input[2] = "" + """ + } + } + + then { + assertAll( + { assert workflow.failed }, + { assert workflow.stdout.any { it.contains('ERROR ~ Validation of pipeline parameters failed!') } } + ) + } + } + + test("Should run nothing - custom schema") { + + when { + + params { + test_data = '' + } + + workflow { + """ + validate_params = false + input[0] = workflow + input[1] = validate_params + input[2] = "${projectDir}/subworkflows/nf-core/utils_nfschema_plugin/tests/nextflow_schema.json" + """ + } + } + + then { + assertAll( + { assert workflow.success } + ) + } + } + + test("Should validate params - custom schema") { + + when { + + params { + test_data = '' + outdir = 1 + } + + workflow { + """ + validate_params = true + input[0] = workflow + input[1] = validate_params + input[2] = "${projectDir}/subworkflows/nf-core/utils_nfschema_plugin/tests/nextflow_schema.json" """ } }