Skip to content

Commit

Permalink
test correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
wow-such-code committed May 15, 2024
1 parent 527c528 commit ef174f8
Showing 1 changed file with 20 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ class DatasetLocatorImplSpec extends Specification {
def "Given a relative path, when a DatasetLocator is created then an IllegalArgumentException is thrown"() {
when:
DatasetLocator locator = DatasetLocatorImpl.of(relativePathExample,
new Provenance("origin","user","id",new ArrayList<String>()))
new Provenance("origin","user","id",new ArrayList<String>(),
new ArrayList<String>()))

then:
thrown(IllegalArgumentException.class)
Expand All @@ -39,7 +40,8 @@ class DatasetLocatorImplSpec extends Specification {
def "Given an absolute path, when a DatasetLocator is created then an instance of this class is returned"() {
when:
DatasetLocator locator = DatasetLocatorImpl.of(flatDataStructureExample,
new Provenance("origin","user","id", new ArrayList<String>()))
new Provenance("origin","user","id", new ArrayList<String>(),
new ArrayList<String>()))

then:
noExceptionThrown()
Expand All @@ -48,7 +50,9 @@ class DatasetLocatorImplSpec extends Specification {
def "Given a structure with more than one file, when the path to the dataset folder is requested, return the absolute path to the parent folder"() {
given:
DatasetLocator locator = DatasetLocatorImpl.of(multiFileDataStructureExample,
new Provenance("origin","user","NGSQABCD006AO-25838529214608",new ArrayList<String>()))
new Provenance("origin","user","NGSQABCD006AO-25838529214608",
new ArrayList<String>(Arrays.asList("NGSQABCD006AO_left.fastq",
"NGSQABCD006AO_right.fastq")),new ArrayList<String>()))

when:
String datasetPath = locator.getPathToDataset()
Expand All @@ -60,7 +64,9 @@ class DatasetLocatorImplSpec extends Specification {
def "Given a flat structure, when the path to the dataset folder is requested, return the given path"() {
given:
DatasetLocator locator = DatasetLocatorImpl.of(flatDataStructureExample,
new Provenance("origin","user","NGSQABCD006AO-25838529214608",new ArrayList<String>()))
new Provenance("origin","user","NGSQABCD006AO-25838529214608",
new ArrayList<String>(Arrays.asList("NGSQABCD006AO-25838529214608.fastq")),
new ArrayList<String>()))

when:
String datasetPath = locator.getPathToDataset()
Expand All @@ -70,19 +76,15 @@ class DatasetLocatorImplSpec extends Specification {
}

def setupMultiFileDataset() {
File file = File.createTempDir()

File dataFolders = new File(file.getAbsolutePath()+
'/NGSQABCD006AO-25838529214608/NGSQABCD006AO-25838529214608_dataset')
dataFolders.mkdirs()
File tempDir = File.createTempDir()

multiFileContainer = dataFolders.getAbsolutePath()
multiFileContainer = tempDir.getAbsolutePath() + File.separator + "data"

new File(dataFolders.getAbsolutePath() + File.separator + "NGSQABCD006AO_left.fastq").createNewFile()
new File(dataFolders.getAbsolutePath() + File.separator + "NGSQABCD006AO_right.fastq").createNewFile()
new File(file.getAbsolutePath() + File.separator + "provenance.json").createNewFile()
new File(tempDir.getAbsolutePath() + File.separator + "NGSQABCD006AO_left.fastq").createNewFile()
new File(tempDir.getAbsolutePath() + File.separator + "NGSQABCD006AO_right.fastq").createNewFile()
new File(tempDir.getAbsolutePath() + File.separator + "provenance.json").createNewFile()

multiFileDataStructureExample = file.getAbsolutePath()
multiFileDataStructureExample = tempDir.getAbsolutePath()
}

def setupRelativePathExample() {
Expand All @@ -91,18 +93,15 @@ class DatasetLocatorImplSpec extends Specification {
}

def setupFlatDatasetExample() {
File file = File.createTempDir()

File dataFolders = new File(file.getAbsolutePath()+'/NGSQABCD006AO-25838529214608.fastq_dataset')
dataFolders.mkdirs()
File tempDir = File.createTempDir()

File singleFile = new File(dataFolders.getAbsolutePath() + File.separator + "NGSQABCD006AO-25838529214608.fastq")
File singleFile = new File(tempDir.getAbsolutePath() + File.separator + "NGSQABCD006AO-25838529214608.fastq")
singleFile.createNewFile()
singleDatasetFile = singleFile.getAbsolutePath()

new File(file.getAbsolutePath() + File.separator + "provenance.json").createNewFile()
new File(tempDir.getAbsolutePath() + File.separator + "provenance.json").createNewFile()

flatDataStructureExample = file.getAbsolutePath()
flatDataStructureExample = tempDir.getAbsolutePath()
}

}

0 comments on commit ef174f8

Please sign in to comment.