From 3a19386df74a5bfd71025d2dc9b4ded1aa039355 Mon Sep 17 00:00:00 2001 From: Dr Marco Claudio De La Pierre Date: Thu, 1 Feb 2024 18:51:22 +0800 Subject: [PATCH] Fix handling of wave.s5cmdConfigUrl setting [ci fast] (#4707) Signed-off-by: Dr Marco Claudio De La Pierre Signed-off-by: Paolo Di Tommaso Co-authored-by: Paolo Di Tommaso --- .../src/main/nextflow/extension/Bolts.groovy | 12 ++++++++++++ .../src/test/nextflow/extension/BoltsTest.groovy | 12 ++++++++++++ .../test/io/seqera/wave/plugin/WaveClientTest.groovy | 9 +++++++++ 3 files changed, 33 insertions(+) diff --git a/modules/nf-commons/src/main/nextflow/extension/Bolts.groovy b/modules/nf-commons/src/main/nextflow/extension/Bolts.groovy index 76622474b8..13d4fc7739 100644 --- a/modules/nf-commons/src/main/nextflow/extension/Bolts.groovy +++ b/modules/nf-commons/src/main/nextflow/extension/Bolts.groovy @@ -443,6 +443,12 @@ class Bolts { else if( type == RateUnit ) { return new RateUnit(self) } + else if ( type == URL ) { + return new URL(self) + } + else if ( type == URI ) { + return URI.create(self) + } StringGroovyMethods.asType(self, type); } @@ -464,6 +470,12 @@ class Bolts { else if( type == MemoryUnit ) { return new MemoryUnit(self.toString()) } + else if ( type == URL ) { + return new URL(self.toString()) + } + else if ( type == URI ) { + return URI.create(self.toString()) + } StringGroovyMethods.asType(self, type); } diff --git a/modules/nf-commons/src/test/nextflow/extension/BoltsTest.groovy b/modules/nf-commons/src/test/nextflow/extension/BoltsTest.groovy index ed39bb220d..c569fb9196 100644 --- a/modules/nf-commons/src/test/nextflow/extension/BoltsTest.groovy +++ b/modules/nf-commons/src/test/nextflow/extension/BoltsTest.groovy @@ -145,6 +145,18 @@ class BoltsTest extends Specification { "$x MB" as MemoryUnit == MemoryUnit.of('5 MB') } + def testAsURL() { + expect: + 'http://foo.com' as URL == new URL('http://foo.com') + 'http://foo.com/some/file.txt' as URL == new URL('http://foo.com/some/file.txt') + } + + def testAsURI() { + expect: + 'http://foo.com' as URI == URI.create('http://foo.com') + 'http://foo.com/some/file.txt' as URI == URI.create('http://foo.com/some/file.txt') + } + def testConfigToMap () { setup: diff --git a/plugins/nf-wave/src/test/io/seqera/wave/plugin/WaveClientTest.groovy b/plugins/nf-wave/src/test/io/seqera/wave/plugin/WaveClientTest.groovy index 7e70745c27..7155221ee5 100644 --- a/plugins/nf-wave/src/test/io/seqera/wave/plugin/WaveClientTest.groovy +++ b/plugins/nf-wave/src/test/io/seqera/wave/plugin/WaveClientTest.groovy @@ -1248,6 +1248,15 @@ class WaveClientTest extends Specification { 'linux/arm64/v8' | 'https://nf-xpack.seqera.io/s5cmd/linux_arm64_2.0.0.json' } + def 'should configure custom s5cmd' () { + given: + def sess = Mock(Session) {getConfig() >> [wave:[s5cmdConfigUrl: 'http://host.com/s5cmd.zip']] } + when: + def wave = Spy(new WaveClient(sess)) + then: + wave.@s5cmdConfigUrl == new URL('http://host.com/s5cmd.zip') + } + def 'should check is local conda file' () { expect: WaveClient.isCondaLocalFile(CONTENT) == EXPECTED