Skip to content

Commit

Permalink
made testing more nf-test style
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonDMurray committed Mar 19, 2024
1 parent 6838c3f commit 2e308c2
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 10 deletions.
48 changes: 38 additions & 10 deletions tests/modules/local/vsearch_derep.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,55 @@ nextflow_process {

when {
params {
//Ensure Nextlfow cleanup function is not set so work directory can be evaluated
clean = false
//Set output directory so specific files can be snapshotted
outdir = "results"
}
process {
"""
input[0] = Channel.of( [ [ "id":"ERR2537816", "single_end": false ], file("${projectDir}/data/derep-input/ERR2537816.filtered.fasta") ] )
input[0] = Channel.of( [ [ "id": "ERR2537816", "single_end": false ], file("${projectDir}/data/derep-input/ERR2537816.filtered.fasta") ] )
"""
}
}

then {
//Check process succeeds
assert process.success
with(process.out) {
assert fasta.size() == 1
assert clustering.size() == 1
assert fasta[0].size() == 2
assert fasta[0][0].size() == 2
assert path(fasta[0].get(1)).md5 == '664eaf12d13a13d32b8caffcb031c48d'
assert path(clustering[0].get(1)).md5 == '35265131266966e6eefe2099725e127b'
//Check each channel individually
with(process.out.fasta) {
//Check one tuple exists
assert size() == 1
with(get(0)) {
//Check first element if tuple is a tuple of expected values
assert get(0) == [ "id": "ERR2537816", "single_end": false ]
//Check second element of tuple is a path to the correct fasta file
assert get(1) ==~ ".*/ERR2537816.derep.fasta"
}
}
with(process.out.clustering) {
//Check one tuple exists
assert size() == 1
with(get(0)) {
//Check first element if tuple is a tuple of expected values
assert get(0) == [ "id": "ERR2537816", "single_end": false ]
//Check second element of tuple is a path to the correct clustering file
assert get(1) ==~ ".*/ERR2537816.derep.uc"
}
}
//Check one log file exists
assert process.out.log.size() == 1
//Check the path is to the correct log file
assert process.out.log.get(0) ==~ ".*/ERR2537816.derep.log"
//Check one versions file exists
assert process.out.versions.size() == 1
//Check the path is to the versions file
assert process.out.versions.get(0) ==~ ".*/versions.yml"
//Check the md5sums of the fasta and clustering
assert snapshot(
path("${params.outdir}/vsearch/derep/ERR2537816.derep.fasta"),
path("${params.outdir}/vsearch/derep/ERR2537816.derep.uc")
).match("vsearch_dereplicate")
}

}

}
13 changes: 13 additions & 0 deletions tests/modules/local/vsearch_derep.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"vsearch_dereplicate": {
"content": [
"ERR2537816.derep.fasta:md5,04090476d9a902ecd8966f67dffd4621",
"ERR2537816.derep.uc:md5,35265131266966e6eefe2099725e127b"
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
},
"timestamp": "2024-03-19T11:17:11.405323"
}
}

0 comments on commit 2e308c2

Please sign in to comment.