Skip to content

Commit

Permalink
improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
drernie committed Sep 4, 2024
1 parent 33fb513 commit 4aefa5e
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ class QuiltFileSystemProvider extends FileSystemProvider implements FileSystemTr
log.debug "QuiltFileSystemProvider.download: ${remoteFile} -> ${localDestination}"
QuiltPath qPath = asQuiltPath(remoteFile)
Path cachedFile = qPath.localPath()
/*
* UNUSED: QuiltPackage is always installed
*
QuiltPackage pkg = qPath.pkg()
if (!pkg.installed) {
log.info "download.install Quilt package: ${pkg}"
Expand All @@ -124,6 +127,7 @@ class QuiltFileSystemProvider extends FileSystemProvider implements FileSystemTr
}
log.info "download.installed Quilt package to: $dest"
}
*/

if (!Files.exists(cachedFile)) {
log.error "download: File ${cachedFile} not found"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ package nextflow.quilt.nio
import nextflow.quilt.QuiltSpecification
import groovy.transform.CompileDynamic
import java.nio.file.Path
import java.nio.file.Paths
import java.nio.file.Files
import java.nio.file.CopyOption
import java.nio.file.StandardCopyOption
import groovy.util.logging.Slf4j
import org.codehaus.groovy.runtime.powerassert.PowerAssertionError

/**
*
Expand All @@ -24,6 +26,16 @@ class QuiltFileSystemProviderTest extends QuiltSpecification {
provider.getScheme() == 'quilt+s3'
}

void 'should error asQuiltPath with non-Quilt path'() {
given:
QuiltFileSystemProvider provider = new QuiltFileSystemProvider()
Path path = Paths.get('README.md')
when:
provider.asQuiltPath(path)
then:
thrown IllegalArgumentException
}

// newDirectoryStream returns local path for read
// newDirectoryStream returns package path for write
// do we need a new schema for quilt+local?
Expand Down Expand Up @@ -58,4 +70,31 @@ class QuiltFileSystemProviderTest extends QuiltSpecification {
Files.list(tempFolder).count() > 0
}

void 'should error when copying from remote to local path'() {
given:
QuiltFileSystemProvider provider = new QuiltFileSystemProvider()
String filename = 'README.md'
Path remoteFile = QuiltPathFactory.parse('quilt+s3://quilt-example#package=examples%2fhurdat2&path=' + filename)
Path tempFolder = Files.createTempDirectory('quilt')
Path tempFile = tempFolder.resolve(filename)

when:
provider.copy(remoteFile, tempFile)

then:
thrown PowerAssertionError
}

void 'should do nothing when copying a path to itself'() {
given:
QuiltFileSystemProvider provider = new QuiltFileSystemProvider()
Path remoteFile = QuiltPathFactory.parse('quilt+s3://quilt-example#package=examples%2fhurdat2&path=README.md')

when:
provider.copy(remoteFile, remoteFile)

then:
Files.exists(remoteFile.localPath())
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ class QuiltNioTest extends QuiltSpecification {
text.startsWith('id')
}

@IgnoreIf({ System.getProperty('os.name').toLowerCase().contains('windows') ||
System.getProperty('os.name').toLowerCase().contains('linux') })
@IgnoreIf({ System.getProperty('os.name').toLowerCase().contains('windows') })
@IgnoreIf({ System.getProperty('os.name').toLowerCase().contains('linux') })
void 'should read file attributes'() {
given:
final start = System.currentTimeMillis()
Expand Down

0 comments on commit 4aefa5e

Please sign in to comment.