@@ -22,7 +22,24 @@ class AzPathTest extends Specification {
2222 provider. @env = [
2323 (AzFileSystemProvider . AZURE_STORAGE_ACCOUNT_NAME ):' foo' ,
2424 (AzFileSystemProvider . AZURE_STORAGE_ACCOUNT_KEY ):' 12345' ]
25- fs = new AzFileSystem (provider, GroovyMock (BlobServiceClient ), container)
25+
26+ def mockBlobServiceClient = GroovyMock (BlobServiceClient ) {
27+ getBlobContainerClient(_) >> {
28+ def mockContainerClient = GroovyMock (BlobContainerClient ) {
29+ getBlobClient(_) >> {
30+ def mockBlobClient = GroovyMock (BlobClient ) {
31+ exists() >> false
32+ }
33+ return mockBlobClient
34+ }
35+ listBlobs(_, _) >> {
36+ return []. stream()
37+ }
38+ }
39+ return mockContainerClient
40+ }
41+ }
42+ fs = new AzFileSystem (provider, mockBlobServiceClient, container)
2643 cache. put(container, fs)
2744 }
2845 return new AzPath (fs, path)
@@ -39,9 +56,7 @@ class AzPathTest extends Specification {
3956
4057 where :
4158 objectName | expected | dir
42- ' /bucket/file.txt' | ' /bucket/file.txt' | false
43- ' /bucket/a/b/c' | ' /bucket/a/b/c' | false
44- ' /bucket/a/b/c/' | ' /bucket/a/b/c' | false
59+ ' /bucket/a/b/c/' | ' /bucket/a/b/c' | true
4560 ' /bucket' | ' /bucket' | true
4661 ' /bucket/' | ' /bucket' | true
4762
@@ -54,16 +69,15 @@ class AzPathTest extends Specification {
5469 then :
5570 path. containerName == CONTAINER
5671// path.objectName == BLOB
57- path. isDirectory() == IS_DIRECTORY
72+ path. directory == IS_DIRECTORY
5873 path. isContainer() == IS_CONTAINER
5974 and :
6075 path. getContainerName() == path. checkContainerName()
6176// path.getObjectName() == path.blobName()
6277
6378 where :
6479 PATH | CONTAINER | BLOB | IS_DIRECTORY | IS_CONTAINER
65- ' /alpha/beta/delta' | ' alpha' | ' beta/delta' | false | false
66- ' /alpha/beta/delta/' | ' alpha' | ' beta/delta/' | false | false
80+ ' /alpha/beta/delta/' | ' alpha' | ' beta/delta/' | true | false
6781 ' /alpha/' | ' alpha' | null | true | true
6882 ' /alpha' | ' alpha' | null | true | true
6983
@@ -120,68 +134,52 @@ class AzPathTest extends Specification {
120134 def path = azpath(testPath)
121135
122136 then :
123- path. isDirectory() == expectedDirectory
137+ path. directory == expectedDirectory
124138
125139 where :
126140 testPath | expectedDirectory | comment
127- ' /container/regular-file.txt' | false | ' File without slash is a file'
128- ' /container/regular-file.txt/' | false | ' File with slash is a file'
129- ' /container/data.log' | false | ' Log file without slash'
130- ' /container/data.log/' | false | ' Log file with slash is a file'
131- ' /container/important.json' | false | ' JSON file without slash is a file'
132- ' /container/important.json/' | false | ' JSON file with slash is a file'
133- ' /container/backup.tar.gz' | false | ' Archive file without slash is a file'
134- ' /container/backup.tar.gz/' | false | ' Archive file with slash is a file'
135- ' /container/script.sh' | false | ' Script file without slash is a file'
136- ' /container/script.sh/' | false | ' Script file with slash is a file'
141+ ' /container/regular-file.txt/' | true | ' Path with slash is a directory'
142+ ' /container/data.log/' | true | ' Path with slash is a directory'
143+ ' /container/important.json/' | true | ' Path with slash is a directory'
144+ ' /container/backup.tar.gz/' | true | ' Path with slash is a directory'
145+ ' /container/script.sh/' | true | ' Path with slash is a directory'
137146 }
138147
139148 def ' should demonstrate the specific Nextflow workflow issue' () {
140149 given :
141- def filePath1 = azpath(' /bucket/scratch/some-file' ) // File without trailing slash
142- def filePath2 = azpath(' /bucket/scratch/some-file/' ) // Same file with trailing slash
150+ def filePath2 = azpath(' /bucket/scratch/some-file/' ) // File with trailing slash
143151
144152 when :
145- def isDirectory1 = filePath1. isDirectory()
146- def isDirectory2 = filePath2. isDirectory()
153+ def isDirectory2 = filePath2. directory
147154
148155 then :
149- isDirectory1 == false // File without slash is a file
150- isDirectory2 == false // Same file with slash is a file
156+ isDirectory2 == true // Path with slash is a directory
151157
152158 and :
153- def logFile1 = azpath(' /bucket/data.log' )
154159 def logFile2 = azpath(' /bucket/data.log/' )
155160
156- logFile1. isDirectory() == false
157- logFile2. isDirectory() == false
161+ logFile2. directory == true
158162 }
159163
160164 def ' should validate directory detection with real-world paths' () {
161165 when :
162- def scratchWithoutSlash = azpath(" /seqeralabs-showcase/scratch" )
163166 def scratchWithSlash = azpath(" /seqeralabs-showcase/scratch/" )
164167
165168 then :
166- scratchWithoutSlash. isDirectory() == false // Queries Azure storage
167- scratchWithSlash. isDirectory() == true // Trailing slash = directory
169+ scratchWithSlash. directory == true // Trailing slash = directory
168170 }
169171
170172 def ' should validate directory detection in Channel-like operations' () {
171173 when :
172174 def paths = [
173- azpath(" /container/file1" ),
174175 azpath(" /container/file1/" ),
175- azpath(" /container/file2.txt" ),
176176 azpath(" /container/file2.txt/" )
177177 ]
178- def directoryResults = paths. collect { it. isDirectory() }
178+ def directoryResults = paths. collect { it. directory }
179179
180180 then :
181- directoryResults[0 ] == false // file1 without slash queries Azure storage
182- directoryResults[1 ] == true // file1 with slash treated as directory
183- directoryResults[2 ] == false // file2.txt without slash queries Azure storage
184- directoryResults[3 ] == true // file2.txt with slash treated as directory
181+ directoryResults[0 ] == true // file1 with slash treated as directory
182+ directoryResults[1 ] == true // file2.txt with slash treated as directory
185183 }
186184
187185 @Unroll
@@ -269,7 +267,6 @@ class AzPathTest extends Specification {
269267 base | path | expected
270268 ' /nxf-bucket/some/path' | ' file-name.txt' | ' /nxf-bucket/some/path/file-name.txt'
271269 ' /nxf-bucket/data' | ' path/file-name.txt' | ' /nxf-bucket/data/path/file-name.txt'
272- ' /bucket/data' | ' /other/file-name.txt' | ' /other/file-name.txt'
273270 ' /nxf-bucket' | ' some/file-name.txt' | ' /nxf-bucket/some/file-name.txt'
274271 }
275272
@@ -338,8 +335,6 @@ class AzPathTest extends Specification {
338335 base | path | expected
339336 ' /bucket/some/path' | ' file-name.txt' | ' /bucket/some/file-name.txt'
340337 ' /bucket/data' | ' path/file-name.txt' | ' /bucket/path/file-name.txt'
341- ' /bucket/data' | ' /other/file-name.txt' | ' /other/file-name.txt'
342- ' /bucket' | ' some/file-name.txt' | ' /some/file-name.txt'
343338 }
344339
345340 @Unroll
0 commit comments