Skip to content

Commit

Permalink
test matchPath
Browse files Browse the repository at this point in the history
  • Loading branch information
drernie committed Aug 24, 2023
1 parent ca40810 commit 7f330a7
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions plugins/nf-quilt/src/test/nextflow/quilt/QuiltObserverTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package nextflow.quilt.nio

import nextflow.quilt.QuiltSpecification
import nextflow.quilt.QuiltObserver
import nextflow.Session

import java.nio.file.Path
import java.nio.file.Paths
Expand All @@ -43,12 +44,17 @@ class QuiltObserverTest extends QuiltSpecification {
given:
String subURL = fullURL.replace('?key=val&key2=val2', '')
String noURL = fullURL.replace('bkt', 'bucket')
Map params = [subdir: subURL, outdir: fullURL, nodir: noURL]
Map normed = QuiltObserver.normalizedPaths(params)
String n_bkt = normed['bkt/pre/suf']
String n_bucket = normed['bucket/pre/suf']
Session session = Stub(Session)
session.getParams() >> [subdir: subURL, outdir: fullURL, nodir: noURL]
QuiltObserver observer = new QuiltObserver()

expect:
when:
observer.onFlowCreate(session)
String n_bkt = observer.packageURIs['bkt/pre/suf']
String n_bucket = observer.packageURIs['bucket/pre/suf']

then:
observer
n_bkt != null
n_bucket != null
fullURL.contains('&path=')
Expand All @@ -57,6 +63,18 @@ class QuiltObserverTest extends QuiltSpecification {
n_bkt.split('#')[0] == 'quilt+s3://bkt?key=val&key2=val2'
n_bkt.contains('quilt+s3://bkt?key=val&key2=val2')
n_bucket.contains('quilt+s3://bucket?key=val&key2=val2')

when:
Path fullPath = QuiltPathFactory.parse(fullURL)
Path subPath = QuiltPathFactory.parse(subURL)
Path noPath = QuiltPathFactory.parse(noURL)
Path bktPath = QuiltPathFactory.parse(n_bkt)
Path bucketPath = QuiltPathFactory.parse(n_bucket)

then:
observer.matchPath(fullPath) == bktPath
observer.matchPath(subPath) == bktPath
observer.matchPath(noPath) == bucketPath
}

}

0 comments on commit 7f330a7

Please sign in to comment.