Skip to content

Commit

Permalink
nf-test custom/sratoolsncbisettings (nf-core#3964)
Browse files Browse the repository at this point in the history
* Add nf-test for custom/sratoolsncbisettings

* Add custom/sratoolsncbisettings to tags

* Update custom/sratoolsncbisettings nf-test

* Remove pytest

* Add tags

* Snap update

* nf-test custom/sratoolsncbisettings fix test

* User configurable tmpdir via environment variable TMPDIR

* add custom configuration file

* Add config

* Add workflow from original test

* Re-add old tests back

* Check stdout of process

* Update tests to user iterator
  • Loading branch information
adamrtalbot authored Oct 12, 2023
1 parent 4e64083 commit c1823cf
Show file tree
Hide file tree
Showing 9 changed files with 135 additions and 103 deletions.
3 changes: 3 additions & 0 deletions .github/modules.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
custom/dumpsoftwareversions:
- modules/nf-core/custom/dumpsoftwareversions/**

custom/sratoolsncbisettings:
- modules/nf-core/custom/sratoolsncbisettings/**

fastqc:
- modules/nf-core/fastqc/**

Expand Down
112 changes: 112 additions & 0 deletions modules/nf-core/custom/sratoolsncbisettings/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
nextflow_process {

name "Test Process CUSTOM_SRATOOLSNCBISETTINGS"
script "../main.nf"
process "CUSTOM_SRATOOLSNCBISETTINGS"
config "modules/nf-core/custom/sratoolsncbisettings/tests/nextflow.config"
tag "custom"
tag "custom/sratoolsncbisettings"

test("Should run without failures") {

when {
params {
settings_path = '/tmp/.ncbi'
settings_file = "${params.settings_path}/user-settings.mkfg"
}

process {
"""
file(params.settings_path).mkdirs()
def settings = file(params.test_data['generic']['config']['ncbi_user_settings'], checkIfExists: true)
settings.copyTo(params.settings_file)
"""
}
}

then {
assert process.success
assert snapshot(
process.out.versions
).match()

with(process.out.ncbi_settings) {
assert path(get(0)).readLines().any { it.contains('/LIBS/GUID') }
assert path(get(0)).readLines().any { it.contains('/libs/cloud/report_instance_identity') }
}
}

}

test("Should fail") {

when {
params {
settings_path = '/tmp/.ncbi'
settings_file = "${params.settings_path}/user-settings.mkfg"
}

process {
"""
file(params.settings_path).mkdirs()
def settings = file(params.settings_file)
settings.text = '''
## auto-generated configuration file - DO NOT EDIT ##
config/default = "false"
/repository/remote/main/CGI/resolver-cgi = "https://trace.ncbi.nlm.nih.gov/Traces/names/names.fcgi"
/repository/remote/protected/CGI/resolver-cgi = "https://trace.ncbi.nlm.nih.gov/Traces/names/names.fcgi"
/repository/user/ad/public/apps/file/volumes/flatAd = "."
/repository/user/ad/public/apps/refseq/volumes/refseqAd = "."
/repository/user/ad/public/apps/sra/volumes/sraAd = "."
/repository/user/ad/public/apps/sraPileup/volumes/ad = "."
/repository/user/ad/public/apps/sraRealign/volumes/ad = "."
/repository/user/ad/public/apps/wgs/volumes/wgsAd = "."
/repository/user/ad/public/root = "."
/repository/user/default-path = "/root/ncbi"
'''.stripIndent()
"""
}
}

then {
assert process.failed
assert snapshot(
process.out.versions
).match()
assert process.stdout.any { it.contains('Command error:') }
assert process.stdout.any { it.contains('missing the required entries') }
assert process.stdout.any { it.contains('/LIBS/GUID') }
assert process.stdout.any { it.contains('/libs/cloud/report_instance_identity') }
}

}

test("Should run with nonexisting") {

when {
params {
settings_path = '/tmp/.ncbi'
settings_file = "${params.settings_path}/user-settings.mkfg"
}

process {
"""
def settings = file(params.settings_file)
settings.delete()
"""
}
}

then {
assert process.success
assert snapshot(process.out.versions).match()

with(process.out.ncbi_settings) {
{ assert path(get(0)).readLines().any { it.contains('/LIBS/GUID') } }
{ assert path(get(0)).readLines().any { it.contains('/libs/cloud/report_instance_identity') } }
}
}

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"Should run with nonexisting": {
"content": [
[
"versions.yml:md5,fec13b593c3b42ddd38f2fc77df25b70"
]
],
"timestamp": "2023-10-12T12:24:24.023849"
},
"Should run without failures": {
"content": [
[
"versions.yml:md5,fec13b593c3b42ddd38f2fc77df25b70"
]
],
"timestamp": "2023-10-12T10:40:51.717351"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ env.NCBI_SETTINGS = params.settings_file
process {

publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" }

withName: CUSTOM_SRATOOLSNCBISETTINGS {
containerOptions = {
(workflow.containerEngine == 'singularity') ?
"-B ${params.settings_path}:${params.settings_path}" :
"-v ${params.settings_path}:${params.settings_path}"
}
}
}
}
2 changes: 1 addition & 1 deletion nf-test.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ config {
testsDir "."

// nf-test directory including temporary files for each test
workDir "/tmp"
workDir System.getenv("TMPDIR") ?: "/var/tmp"

// location of an optional nextflow.config file specific for executing tests
configFile "tests/config/nf-test.config"
Expand Down
4 changes: 0 additions & 4 deletions tests/config/pytest_modules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -906,10 +906,6 @@ custom/matrixfilter:
- modules/nf-core/custom/matrixfilter/**
- tests/modules/nf-core/custom/matrixfilter/**

custom/sratoolsncbisettings:
- modules/nf-core/custom/sratoolsncbisettings/**
- tests/modules/nf-core/custom/sratoolsncbisettings/**

custom/tabulartogseacls:
- modules/nf-core/custom/tabulartogseacls/**
- tests/modules/nf-core/custom/tabulartogseacls/**
Expand Down
44 changes: 0 additions & 44 deletions tests/modules/nf-core/custom/sratoolsncbisettings/main.nf

This file was deleted.

This file was deleted.

44 changes: 0 additions & 44 deletions tests/modules/nf-core/custom/sratoolsncbisettings/test.yml

This file was deleted.

0 comments on commit c1823cf

Please sign in to comment.