Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nvnieuwk committed Apr 9, 2024
1 parent 2352139 commit 3772bea
Showing 1 changed file with 111 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ class SamplesheetConverterTest extends Dsl2Spec{
def SCRIPT_TEXT = '''
include { fromSamplesheet } from 'plugin/nf-schema'
params.input = 'src/testResources/correct.csv'
workflow {
Channel.fromSamplesheet("input", parameters_schema:"src/testResources/nextflow_schema_with_samplesheet_converter.json").view().first().map {println(it[0].getClass())}
Channel.of("src/testResources/correct.csv")
.fromSamplesheet("src/testResources/schema_input.json")
.view()
}
'''

Expand All @@ -88,10 +88,10 @@ class SamplesheetConverterTest extends Dsl2Spec{
def SCRIPT_TEXT = '''
include { fromSamplesheet } from 'plugin/nf-schema'
params.input = 'src/testResources/correct_quoted.csv'
workflow {
Channel.fromSamplesheet("input", parameters_schema:"src/testResources/nextflow_schema_with_samplesheet_converter.json").view().first().map {println(it[0].getClass())}
Channel.fromPath('src/testResources/correct_quoted.csv')
.fromSamplesheet("src/testResources/schema_input.json")
.view()
}
'''

Expand All @@ -115,10 +115,10 @@ class SamplesheetConverterTest extends Dsl2Spec{
def SCRIPT_TEXT = '''
include { fromSamplesheet } from 'plugin/nf-schema'
params.input = 'src/testResources/correct.tsv'
workflow {
Channel.fromSamplesheet("input", parameters_schema:"src/testResources/nextflow_schema_with_samplesheet_converter.json").view()
Channel.of('src/testResources/correct.tsv')
.fromSamplesheet(file("src/testResources/schema_input.json", checkIfExists:true))
.view()
}
'''

Expand All @@ -142,10 +142,10 @@ class SamplesheetConverterTest extends Dsl2Spec{
def SCRIPT_TEXT = '''
include { fromSamplesheet } from 'plugin/nf-schema'
params.input = 'src/testResources/correct.yaml'
workflow {
Channel.fromSamplesheet("input", parameters_schema:"src/testResources/nextflow_schema_with_samplesheet_converter.json").view()
Channel.of('src/testResources/correct.yaml')
.fromSamplesheet("src/testResources/schema_input.json")
.view()
}
'''

Expand All @@ -169,10 +169,10 @@ class SamplesheetConverterTest extends Dsl2Spec{
def SCRIPT_TEXT = '''
include { fromSamplesheet } from 'plugin/nf-schema'
params.input = 'src/testResources/correct.json'
workflow {
Channel.fromSamplesheet("input", parameters_schema:"src/testResources/nextflow_schema_with_samplesheet_converter.json").view()
Channel.of('src/testResources/correct.json')
.fromSamplesheet("src/testResources/schema_input.json")
.view()
}
'''

Expand All @@ -196,10 +196,10 @@ class SamplesheetConverterTest extends Dsl2Spec{
def SCRIPT_TEXT = '''
include { fromSamplesheet } from 'plugin/nf-schema'
params.input = 'src/testResources/correct_arrays.yaml'
workflow {
Channel.fromSamplesheet("input", parameters_schema:"src/testResources/nextflow_schema_with_samplesheet_converter_arrays.json").view()
Channel.of('src/testResources/correct_arrays.yaml')
.fromSamplesheet("src/testResources/schema_input_with_arrays.json")
.view()
}
'''

Expand All @@ -222,10 +222,10 @@ class SamplesheetConverterTest extends Dsl2Spec{
def SCRIPT_TEXT = '''
include { fromSamplesheet } from 'plugin/nf-schema'
params.input = 'src/testResources/correct_arrays.json'
workflow {
Channel.fromSamplesheet("input", parameters_schema:"src/testResources/nextflow_schema_with_samplesheet_converter_arrays.json").view()
Channel.of('src/testResources/correct_arrays.json')
.fromSamplesheet("src/testResources/schema_input_with_arrays.json")
.view()
}
'''

Expand All @@ -248,10 +248,10 @@ class SamplesheetConverterTest extends Dsl2Spec{
def SCRIPT_TEXT = '''
include { fromSamplesheet } from 'plugin/nf-schema'
params.input = 'src/testResources/no_header.csv'
workflow {
Channel.fromSamplesheet("input", parameters_schema:"src/testResources/nextflow_schema_with_samplesheet_no_header.json").view()
Channel.of('src/testResources/no_header.csv')
.fromSamplesheet("src/testResources/no_header_schema.json")
.view()
}
'''

Expand All @@ -272,10 +272,10 @@ class SamplesheetConverterTest extends Dsl2Spec{
def SCRIPT_TEXT = '''
include { fromSamplesheet } from 'plugin/nf-schema'
params.input = 'src/testResources/no_header.yaml'
workflow {
Channel.fromSamplesheet("input", parameters_schema:"src/testResources/nextflow_schema_with_samplesheet_no_header.json").view()
Channel.of('src/testResources/no_header.yaml')
.fromSamplesheet("src/testResources/no_header_schema.json")
.view()
}
'''

Expand All @@ -296,10 +296,10 @@ class SamplesheetConverterTest extends Dsl2Spec{
def SCRIPT_TEXT = '''
include { fromSamplesheet } from 'plugin/nf-schema'
params.input = 'src/testResources/no_header.json'
workflow {
Channel.fromSamplesheet("input", parameters_schema:"src/testResources/nextflow_schema_with_samplesheet_no_header.json").view()
Channel.of('src/testResources/no_header.json')
.fromSamplesheet("src/testResources/no_header_schema.json")
.view()
}
'''

Expand All @@ -320,10 +320,10 @@ class SamplesheetConverterTest extends Dsl2Spec{
def SCRIPT_TEXT = '''
include { fromSamplesheet } from 'plugin/nf-schema'
params.input = 'src/testResources/extraFields.csv'
workflow {
Channel.fromSamplesheet("input", parameters_schema:"src/testResources/nextflow_schema_with_samplesheet_converter.json").view()
Channel.of('src/testResources/extraFields.csv')
.fromSamplesheet("src/testResources/schema_input.json")
.view()
}
'''

Expand Down Expand Up @@ -351,10 +351,10 @@ class SamplesheetConverterTest extends Dsl2Spec{
def SCRIPT_TEXT = '''
include { fromSamplesheet } from 'plugin/nf-schema'
params.input = 'src/testResources/no_meta.csv'
workflow {
Channel.fromSamplesheet("input", parameters_schema:"src/testResources/nextflow_schema_with_samplesheet_no_meta.json").view()
Channel.of('src/testResources/no_meta.csv')
.fromSamplesheet("src/testResources/no_meta_schema.json")
.view()
}
'''

Expand All @@ -375,10 +375,10 @@ class SamplesheetConverterTest extends Dsl2Spec{
def SCRIPT_TEXT = '''
include { fromSamplesheet } from 'plugin/nf-schema'
params.input = 'src/testResources/deeply_nested.yaml'
workflow {
Channel.fromSamplesheet("input", parameters_schema:"src/testResources/nextflow_schema_with_deeply_nested_samplesheet.json").view()
Channel.of('src/testResources/deeply_nested.yaml')
.fromSamplesheet("src/testResources/samplesheet_schema_deeply_nested.json")
.view()
}
'''

Expand All @@ -399,10 +399,10 @@ class SamplesheetConverterTest extends Dsl2Spec{
def SCRIPT_TEXT = '''
include { fromSamplesheet } from 'plugin/nf-schema'
params.input = 'src/testResources/deeply_nested.json'
workflow {
Channel.fromSamplesheet("input", parameters_schema:"src/testResources/nextflow_schema_with_deeply_nested_samplesheet.json").view()
Channel.of('src/testResources/deeply_nested.json')
.fromSamplesheet("src/testResources/samplesheet_schema_deeply_nested.json")
.view()
}
'''

Expand All @@ -417,4 +417,73 @@ class SamplesheetConverterTest extends Dsl2Spec{
noExceptionThrown()
stdout.contains("[[mapMeta:this is in a map, arrayMeta:[metaString45, metaString478], otherArrayMeta:[metaString45, metaString478], meta:metaValue, metaMap:[entry1:entry1String, entry2:12.56]], [[string1, string2], string3, 1, 1, ${getRootString()}/file1.txt], [string4, string5, string6], [[string7, string8], [string9, string10]], test]" as String)
}

def 'samplesheetToList - String, String' () {
given:
def SCRIPT_TEXT = '''
include { samplesheetToList } from 'plugin/nf-schema'
println(samplesheetToList("src/testResources/correct.csv", "src/testResources/schema_input.json").join("\\n"))
'''

when:
dsl_eval(SCRIPT_TEXT)
def stdout = capture
.toString()
.readLines()
.findResults {it.startsWith('[[') ? it : null }

then:
noExceptionThrown()
stdout.contains("[[string1:fullField, string2:fullField, integer1:10, integer2:10, boolean1:true, boolean2:true], string1, 25.12, false, ${getRootString()}/src/testResources/test.txt, ${getRootString()}/src/testResources/testDir, ${getRootString()}/src/testResources/test.txt, unique1, 1, itDoesExist]" as String)
stdout.contains("[[string1:value, string2:value, integer1:0, integer2:0, boolean1:true, boolean2:true], string1, 25.08, false, [], [], [], [], [], itDoesExist]")
stdout.contains("[[string1:dependentRequired, string2:dependentRequired, integer1:10, integer2:10, boolean1:true, boolean2:true], string1, 25, false, [], [], [], unique2, 1, itDoesExist]")
stdout.contains("[[string1:extraField, string2:extraField, integer1:10, integer2:10, boolean1:true, boolean2:true], string1, 25, false, ${getRootString()}/src/testResources/test.txt, ${getRootString()}/src/testResources/testDir, ${getRootString()}/src/testResources/testDir, unique3, 1, itDoesExist]" as String)
}

def 'samplesheetToList - Path, String' () {
given:
def SCRIPT_TEXT = '''
include { samplesheetToList } from 'plugin/nf-schema'
println(samplesheetToList(file("src/testResources/correct.csv", checkIfExists:true), "src/testResources/schema_input.json").join("\\n"))
'''

when:
dsl_eval(SCRIPT_TEXT)
def stdout = capture
.toString()
.readLines()
.findResults {it.startsWith('[[') ? it : null }

then:
noExceptionThrown()
stdout.contains("[[string1:fullField, string2:fullField, integer1:10, integer2:10, boolean1:true, boolean2:true], string1, 25.12, false, ${getRootString()}/src/testResources/test.txt, ${getRootString()}/src/testResources/testDir, ${getRootString()}/src/testResources/test.txt, unique1, 1, itDoesExist]" as String)
stdout.contains("[[string1:value, string2:value, integer1:0, integer2:0, boolean1:true, boolean2:true], string1, 25.08, false, [], [], [], [], [], itDoesExist]")
stdout.contains("[[string1:dependentRequired, string2:dependentRequired, integer1:10, integer2:10, boolean1:true, boolean2:true], string1, 25, false, [], [], [], unique2, 1, itDoesExist]")
stdout.contains("[[string1:extraField, string2:extraField, integer1:10, integer2:10, boolean1:true, boolean2:true], string1, 25, false, ${getRootString()}/src/testResources/test.txt, ${getRootString()}/src/testResources/testDir, ${getRootString()}/src/testResources/testDir, unique3, 1, itDoesExist]" as String)
}

def 'samplesheetToList - String, Path' () {
given:
def SCRIPT_TEXT = '''
include { samplesheetToList } from 'plugin/nf-schema'
println(samplesheetToList("src/testResources/correct.csv", file("src/testResources/schema_input.json", checkIfExists:true)).join("\\n"))
'''

when:
dsl_eval(SCRIPT_TEXT)
def stdout = capture
.toString()
.readLines()
.findResults {it.startsWith('[[') ? it : null }

then:
noExceptionThrown()
stdout.contains("[[string1:fullField, string2:fullField, integer1:10, integer2:10, boolean1:true, boolean2:true], string1, 25.12, false, ${getRootString()}/src/testResources/test.txt, ${getRootString()}/src/testResources/testDir, ${getRootString()}/src/testResources/test.txt, unique1, 1, itDoesExist]" as String)
stdout.contains("[[string1:value, string2:value, integer1:0, integer2:0, boolean1:true, boolean2:true], string1, 25.08, false, [], [], [], [], [], itDoesExist]")
stdout.contains("[[string1:dependentRequired, string2:dependentRequired, integer1:10, integer2:10, boolean1:true, boolean2:true], string1, 25, false, [], [], [], unique2, 1, itDoesExist]")
stdout.contains("[[string1:extraField, string2:extraField, integer1:10, integer2:10, boolean1:true, boolean2:true], string1, 25, false, ${getRootString()}/src/testResources/test.txt, ${getRootString()}/src/testResources/testDir, ${getRootString()}/src/testResources/testDir, unique3, 1, itDoesExist]" as String)
}
}

0 comments on commit 3772bea

Please sign in to comment.