@@ -20,6 +20,7 @@ import nextflow.ga4gh.tes.client.api.TaskServiceApi
2020import nextflow.ga4gh.tes.client.model.TesCreateTaskResponse
2121import nextflow.ga4gh.tes.client.model.TesTask
2222import nextflow.processor.TaskStatus
23+ import nextflow.script.params.FileOutParam
2324
2425import java.nio.file.Path
2526import java.nio.file.Paths
@@ -89,4 +90,78 @@ class TesTaskHandlerTest extends Specification {
8990 handler. requestId == ' 12345'
9091 }
9192
93+ def ' should add outputs to both workDir and storeDir when storeDir is configured' () {
94+
95+ given :
96+ def executor = Mock (TesExecutor )
97+ def storeDirUri = " s3://some/store/dir"
98+ def workDir = Paths . get(" /work/dir" )
99+ def fileOutParam = Mock (FileOutParam )
100+ fileOutParam. type >> ' file'
101+ fileOutParam. getFilePatterns(_, _) >> [' output.txt' , ' result.log' ]
102+
103+ def task = Mock (TaskRun ) {
104+ getInputFilesMap() >> [:]
105+ getOutputFilesNames() >> []
106+ getOutputsByType(FileOutParam ) >> [(fileOutParam): null ]
107+ getWorkDir() >> workDir
108+ }
109+ task. getName() >> ' tes-task'
110+ def config = Mock (TaskConfig )
111+ config. get(' storeDir' ) >> storeDirUri
112+ task. getConfig() >> config
113+ task. getContainer() >> ' foo'
114+ def handler = new TesTaskHandler (task, executor)
115+
116+ when :
117+ def tesTask = handler. newTesTask()
118+
119+ then :
120+ def outputs = tesTask. getOutputs()
121+
122+ def workDirOutputs = outputs. findAll { it. url. startsWith(workDir. toUriString()) }
123+
124+ def storeDirOutputs = outputs. findAll { it. url. startsWith(storeDirUri) }
125+
126+ storeDirOutputs. size() == 2
127+ storeDirOutputs. any { it. url. endsWith(' output.txt' ) }
128+ storeDirOutputs. any { it. url. endsWith(' result.log' ) }
129+
130+ workDirOutputs. size() >= 2
131+ }
132+
133+ def ' should not add storeDir outputs when storeDir is not configured' () {
134+
135+ given :
136+ def executor = Mock (TesExecutor )
137+ def workDir = Paths . get(" /work/dir" )
138+ def fileOutParam = Mock (FileOutParam )
139+ fileOutParam. type >> ' file'
140+ fileOutParam. getFilePatterns(_, _) >> [' output.txt' ]
141+
142+ def task = Mock (TaskRun ) {
143+ getInputFilesMap() >> [:]
144+ getOutputFilesNames() >> []
145+ getOutputsByType(FileOutParam ) >> [(fileOutParam): null ]
146+ getWorkDir() >> workDir
147+ }
148+ task. getName() >> ' tes-task'
149+ def config = Mock (TaskConfig )
150+ config. get(' storeDir' ) >> null
151+ task. getConfig() >> config
152+ task. getContainer() >> ' foo'
153+ def handler = new TesTaskHandler (task, executor)
154+
155+ when :
156+ def tesTask = handler. newTesTask()
157+
158+ then :
159+ def outputs = tesTask. getOutputs()
160+
161+ def workDirOutputs = outputs. findAll { it. url. startsWith(workDir. toUriString()) }
162+ workDirOutputs. size() >= 1
163+
164+ outputs. every { it. url. startsWith(workDir. toUriString()) }
165+ }
166+
92167}
0 commit comments