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

Add nf-test to unzip module #5357

Closed
wants to merge 13 commits into from
14 changes: 13 additions & 1 deletion modules/nf-core/unzip/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ process UNZIP {
script:
def args = task.ext.args ?: ''
if ( archive instanceof List && archive.name.size > 1 ) { error "[UNZIP] error: 7za only accepts a single archive as input. Please check module input." }

prefix = task.ext.prefix ?: ( meta.id ? "${meta.id}" : archive.baseName)
"""
7za \\
Expand All @@ -34,4 +33,17 @@ process UNZIP {
7za: \$(echo \$(7za --help) | sed 's/.*p7zip Version //; s/(.*//')
END_VERSIONS
"""

stub:
def args = task.ext.args ?: ''
if ( archive instanceof List && archive.name.size > 1 ) { error "[UNZIP] error: 7za only accepts a single archive as input. Please check module input." }
prefix = task.ext.prefix ?: ( meta.id ? "${meta.id}" : archive.baseName)
"""
mkdir "${prefix}"
cat <<-END_VERSIONS > versions.yml
"${task.process}":
7za: \$(echo \$(7za --help) | sed 's/.*p7zip Version //; s/(.*//')
END_VERSIONS
"""
}
56 changes: 56 additions & 0 deletions modules/nf-core/unzip/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
nextflow_process {

name "Test Process UNZIP"
script "../main.nf"
process "UNZIP"

tag "modules"
tag "modules_nfcore"
tag "unzip"

test("generic [tar] [tar_gz]") {

when {
process {
"""
input[0] = [
[ id: 'hello' ],
file(params.test_data['generic']['tar']['tar_gz'], checkIfExists: true)
]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert path(process.out.unzipped_archive.get(0).get(1)).exists() },
{ assert snapshot(process.out.unzipped_archive).match("unzipped_archive") },
{ assert snapshot(process.out.versions).match("versions") }
)
}
}

test("generic [tar] [tar_gz] stub") {

options "-stub"

when {
process {
"""
input[0] = [
[ id: 'stub' ],
file(params.test_data['generic']['tar']['tar_gz'], checkIfExists: true)
]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match("stub") }
)
}
}
}
70 changes: 70 additions & 0 deletions modules/nf-core/unzip/tests/main.nf.test.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions modules/nf-core/unzip/tests/tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
unzip:
- "modules/nf-core/unzip/**"
12 changes: 12 additions & 0 deletions modules/nf-core/unzipfiles/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,16 @@ process UNZIPFILES {
7za: \$(echo \$(7za --help) | sed 's/.*p7zip Version //; s/(.*//')
END_VERSIONS
"""

stub:
prefix = task.ext.prefix ?: ( meta.id ? "${meta.id}" : archive.baseName)
"""
mkdir "${prefix}"
touch "${prefix}/hello.txt"
cat <<-END_VERSIONS > versions.yml
"${task.process}":
7za: \$(echo \$(7za --help) | sed 's/.*p7zip Version //; s/(.*//')
END_VERSIONS
"""
}
57 changes: 57 additions & 0 deletions modules/nf-core/unzipfiles/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
nextflow_process {

name "Test Process UNZIPFILES"
script "../main.nf"
process "UNZIPFILES"

tag "modules"
tag "modules_nfcore"
tag "unzipfiles"

test("generic [tar] [tar_gz]") {

when {
process {
"""
input[0] = [
[ id: 'hello' ],
file(params.test_data['generic']['tar']['tar_gz'], checkIfExists: true)
]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert path(process.out.files.get(0).get(1)).exists() },
{ assert snapshot(process.out.files).match("files") },
{ assert snapshot(process.out.versions).match("versions") }
)
}
}

test("generic [tar] [tar_gz] stub") {

options "-stub"

when {
process {
"""
input[0] = [
[ id: 'stub' ],
file(params.test_data['generic']['tar']['tar_gz'], checkIfExists: true)
]
"""
}
}

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

}
64 changes: 64 additions & 0 deletions modules/nf-core/unzipfiles/tests/main.nf.test.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions modules/nf-core/unzipfiles/tests/tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
unzipfiles:
- "modules/nf-core/unzipfiles/**"
6 changes: 0 additions & 6 deletions tests/config/pytest_modules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2171,12 +2171,6 @@ universc:
untarfiles:
- modules/nf-core/untarfiles/**
- tests/modules/nf-core/untarfiles/**
unzip:
- modules/nf-core/unzip/**
- tests/modules/nf-core/unzip/**
unzipfiles:
- modules/nf-core/unzipfiles/**
- tests/modules/nf-core/unzipfiles/**
upd:
- modules/nf-core/upd/**
- tests/modules/nf-core/upd/**
Expand Down
16 changes: 0 additions & 16 deletions tests/modules/nf-core/unzip/main.nf

This file was deleted.

5 changes: 0 additions & 5 deletions tests/modules/nf-core/unzip/nextflow.config

This file was deleted.

11 changes: 0 additions & 11 deletions tests/modules/nf-core/unzip/test.yml

This file was deleted.

16 changes: 0 additions & 16 deletions tests/modules/nf-core/unzipfiles/main.nf

This file was deleted.

5 changes: 0 additions & 5 deletions tests/modules/nf-core/unzipfiles/nextflow.config

This file was deleted.

11 changes: 0 additions & 11 deletions tests/modules/nf-core/unzipfiles/test.yml

This file was deleted.

Loading