Skip to content

Commit 8dc48d1

Browse files
committed
Update nextflow XPath test
1 parent 97122fc commit 8dc48d1

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

subworkflows/local/utils_nfcore_phaseimpute_pipeline/main.nf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -541,17 +541,17 @@ def checkMetaChr(chr_a, chr_b, name){
541541
//
542542
def getFileExtension(file) {
543543
def file_name = ""
544-
545-
if (file instanceof Path || file instanceof nextflow.file.http.XPath) {
544+
if (file instanceof Path) {
546545
file_name = file.name
546+
} else if (file instanceof java.net.URL) {
547+
file_name = file.path.tokenize('/')[-1]
547548
} else if (file instanceof CharSequence) {
548549
file_name = file.toString()
549550
} else if (file instanceof List) {
550551
return file.collect { getFileExtension(it) }
551552
} else {
552553
error "Type not supported: ${file.getClass()}"
553554
}
554-
555555
// Remove .gz if present and get the last part after splitting by "."
556556
return file_name.replace(".gz", "").split("\\.").last()
557557
}

subworkflows/local/utils_nfcore_phaseimpute_pipeline/tests/function.nf.test

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,18 @@ nextflow_function {
3434
"""
3535
input[0] = [
3636
file(params.pipelines_testdata_base_path + "hum_data/panel/chr21/1000GP.chr21.s.norel.vcf.gz", checkIfExists: true),
37-
"test.myfile.txt.gz"
37+
"test.myfile.txt.gz",
38+
new URL("https://example.com/data.tar.gz"),
39+
new URL("https://example.com/subsite/data.vcf"),
40+
nextflow.file.http.XPath.get('http://www.nextflow.io/a/b/c.txt')
3841
]
3942
"""
4043
}
4144
}
4245
then {
4346
assertAll(
4447
{ assert function.success },
45-
{ assert function.result == ['vcf', 'txt'] },
48+
{ assert function.result == ['vcf', 'txt', 'tar', 'vcf', 'txt'] },
4649
{ assert snapshot(function.result).match() }
4750
)
4851
}

subworkflows/local/utils_nfcore_phaseimpute_pipeline/tests/function.nf.test.snap

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,18 @@
6666
"Test getFileExtension non empty list": {
6767
"content": [
6868
[
69+
"vcf",
70+
"txt",
71+
"tar",
6972
"vcf",
7073
"txt"
7174
]
7275
],
7376
"meta": {
7477
"nf-test": "0.9.1",
75-
"nextflow": "24.10.0"
78+
"nextflow": "24.10.4"
7679
},
77-
"timestamp": "2024-10-31T13:15:08.856706046"
80+
"timestamp": "2025-03-03T15:47:37.629077209"
7881
},
7982
"Test validateInputBatchTools error batch": {
8083
"content": [

0 commit comments

Comments
 (0)