Skip to content

Commit

Permalink
improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
drernie committed Sep 11, 2024
1 parent e8855dd commit d9b48a2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
6 changes: 4 additions & 2 deletions plugins/nf-quilt/src/main/nextflow/quilt/QuiltObserver.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,11 @@ class QuiltObserver implements TraceObserver {
String destString = QuiltPackage.osConvert(dest.toAbsolutePath().normalize().toString())
// find pkgKey in destination.toString()
int index = destString.indexOf(pkgKey)
println("pkgRelative[$index]: $pkgKey in $destString")
// return the portion after the end of pkgKey
if (index >= 0) {
return destString.substring(index + pkgKey.length() + 1)
int len = index + pkgKey.length() + 1
if (index >= 0 && len < destString.length()) {
return destString.substring(len)
}
return null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,16 @@ class QuiltObserverTest extends QuiltSpecification {
void 'should addOverlay logical path with subfolders'() {
given:
QuiltObserver observer = makeObserver()
String file_path = 'file.txt'
String full_path = "output/${file_path}"
Path source = Paths.get(TEST_KEY, file_path)
Path dest = Paths.get(TEST_KEY, full_path)
String file_path = 'source'
Path source = Paths.get(root, file_path)
Path dest = Paths.get(root, path)
expect:
String relPath = observer.addOverlay(TEST_KEY, dest, source)
relPath == full_path
relPath == result
where:
root | path | result
TEST_KEY | SPEC_KEY | SPEC_KEY
SPEC_KEY | TEST_KEY | null
}

void 'should not error on onFlowComplete success'() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,18 @@ class QuiltFileSystemProviderTest extends QuiltSpecification {
Files.list(tempFolder).count() > 0
}

void 'should fail to download a file if already exists'() {
given:
QuiltFileSystemProvider provider = new QuiltFileSystemProvider()
Path remoteFolder = parsedURIWithPath(false)
Path tempFolder = Files.createTempDirectory('quilt')
when:
provider.download(remoteFolder, tempFolder, null)

then:
thrown java.nio.file.FileAlreadyExistsException
}

@IgnoreIf({ env.WRITE_BUCKET == null })
void 'should upload file to test bucket'() {
given:
Expand Down

0 comments on commit d9b48a2

Please sign in to comment.