@@ -134,10 +134,6 @@ func TestAirflow2(t *testing.T) {
134134 mockBucket .On ("WriteAll" , mock .Anything , "dags/__lib.py" , airflow2 .SharedLib , (* blob .WriterOptions )(nil )).Return (nil )
135135 mockBucket .On ("WriteAll" , ctx , fmt .Sprintf ("dags/%s/%s.py" , ns .Name , jobSpecs [0 ].Name ), []byte ("job-1-compiled" ), (* blob .WriterOptions )(nil )).Return (nil )
136136 mockBucket .On ("Delete" , ctx , fmt .Sprintf ("dags/%s/%s.py" , ns .ID .String (), jobSpecs [0 ].Name )).Return (nil )
137- mockBucket .On ("Delete" , ctx , fmt .Sprintf ("dags/%s" , ns .ID .String ())).Return (nil )
138- mockBucket .On ("List" , & blob.ListOptions {
139- Prefix : fmt .Sprintf ("dags/%s" , ns .ID .String ()),
140- }).Return (& blob.ListIterator {})
141137
142138 expectedDeployDetail := models.JobDeploymentDetail {
143139 SuccessCount : 1 ,
@@ -211,23 +207,27 @@ func TestAirflow2(t *testing.T) {
211207 })
212208 t .Run ("DeleteJobs" , func (t * testing.T ) {
213209 t .Run ("should successfully delete jobs from blob buckets" , func (t * testing.T ) {
214- jobKey := fmt .Sprintf ("dags/%s/%s.py" , nsUUID , jobSpecs [0 ].Name )
210+ jobKey := fmt .Sprintf ("dags/%s/%s.py" , ns . Name , jobSpecs [0 ].Name )
215211
216212 inMemBlob := memblob .OpenBucket (nil )
217213 _ = inMemBlob .WriteAll (ctx , jobKey , []byte ("hello" ), nil )
218214
219215 mockBucket := & MockedBucket {
220216 bucket : inMemBlob ,
221217 }
222- mockBucket .On ("Delete" , mock .Anything , fmt .Sprintf ("dags/%s/%s.py" , nsUUID , jobSpecs [0 ].Name )).Return (nil )
218+ mockBucket .On ("Delete" , mock .Anything , fmt .Sprintf ("dags/%s/%s.py" , ns .Name , jobSpecs [0 ].Name )).Return (nil )
219+ mockBucket .On ("Delete" , mock .Anything , fmt .Sprintf ("dags/%s" , ns .Name )).Return (nil )
220+ mockBucket .On ("List" , & blob.ListOptions {
221+ Prefix : fmt .Sprintf ("dags/%s" , ns .Name ),
222+ }).Return (& blob.ListIterator {})
223223 defer mockBucket .AssertExpectations (t )
224224
225225 mockBucketFac := new (MockedBucketFactory )
226226 mockBucketFac .On ("New" , mock .Anything , proj ).Return (mockBucket , nil )
227227 defer mockBucketFac .AssertExpectations (t )
228228
229229 air := airflow2 .NewScheduler (mockBucketFac , nil , nil )
230- err := air .DeleteJobs (ctx , ns , []string {"job-1" }, nil )
230+ err := air .DeleteJobs (ctx , ns . Name , ns , []string {"job-1" }, nil )
231231 assert .Nil (t , err )
232232
233233 jobStillExist , err := inMemBlob .Exists (ctx , jobKey )
@@ -239,15 +239,19 @@ func TestAirflow2(t *testing.T) {
239239 mockBucket := & MockedBucket {
240240 bucket : inMemBlob ,
241241 }
242- mockBucket .On ("Delete" , mock .Anything , fmt .Sprintf ("dags/%s/%s.py" , nsUUID , jobSpecs [0 ].Name )).Return (nil )
242+ mockBucket .On ("Delete" , mock .Anything , fmt .Sprintf ("dags/%s/%s.py" , ns .Name , jobSpecs [0 ].Name )).Return (nil )
243+ mockBucket .On ("Delete" , mock .Anything , fmt .Sprintf ("dags/%s" , ns .Name )).Return (nil )
244+ mockBucket .On ("List" , & blob.ListOptions {
245+ Prefix : fmt .Sprintf ("dags/%s" , ns .Name ),
246+ }).Return (& blob.ListIterator {})
243247 defer mockBucket .AssertExpectations (t )
244248
245249 mockBucketFac := new (MockedBucketFactory )
246250 mockBucketFac .On ("New" , mock .Anything , proj ).Return (mockBucket , nil )
247251 defer mockBucketFac .AssertExpectations (t )
248252
249253 air := airflow2 .NewScheduler (mockBucketFac , nil , nil )
250- err := air .DeleteJobs (ctx , ns , []string {"job-1" }, nil )
254+ err := air .DeleteJobs (ctx , ns . Name , ns , []string {"job-1" }, nil )
251255 assert .Nil (t , err )
252256 })
253257 })
@@ -257,11 +261,11 @@ func TestAirflow2(t *testing.T) {
257261 mockBucket := & MockedBucket {
258262 bucket : inMemBlob ,
259263 }
260- _ = inMemBlob .WriteAll (ctx , filepath .Join (airflow2 .PathForJobDirectory (airflow2 .JobsDir , ns .ID . String () ), "file1.py" ), []byte ("test1" ), nil )
261- _ = inMemBlob .WriteAll (ctx , filepath .Join (airflow2 .PathForJobDirectory (airflow2 .JobsDir , ns .ID . String () ), "file2.py" ), []byte ("test2" ), nil )
264+ _ = inMemBlob .WriteAll (ctx , filepath .Join (airflow2 .PathForJobDirectory (airflow2 .JobsDir , ns .Name ), "file1.py" ), []byte ("test1" ), nil )
265+ _ = inMemBlob .WriteAll (ctx , filepath .Join (airflow2 .PathForJobDirectory (airflow2 .JobsDir , ns .Name ), "file2.py" ), []byte ("test2" ), nil )
262266 _ = inMemBlob .WriteAll (ctx , "bar.py" , []byte ("test3" ), nil )
263267 mockBucket .On ("List" , & blob.ListOptions {
264- Prefix : airflow2 .PathForJobDirectory (airflow2 .JobsDir , ns .ID . String () ),
268+ Prefix : airflow2 .PathForJobDirectory (airflow2 .JobsDir , ns .Name ),
265269 })
266270 defer mockBucket .AssertExpectations (t )
267271
@@ -270,7 +274,7 @@ func TestAirflow2(t *testing.T) {
270274 defer mockBucketFac .AssertExpectations (t )
271275
272276 air := airflow2 .NewScheduler (mockBucketFac , nil , nil )
273- respJobs , err := air .ListJobs (ctx , ns , models.SchedulerListOptions {OnlyName : true })
277+ respJobs , err := air .ListJobs (ctx , ns . Name , ns , models.SchedulerListOptions {OnlyName : true })
274278 assert .Nil (t , err )
275279 assert .Equal (t , 2 , len (respJobs ))
276280 })
@@ -279,11 +283,11 @@ func TestAirflow2(t *testing.T) {
279283 mockBucket := & MockedBucket {
280284 bucket : inMemBlob ,
281285 }
282- _ = inMemBlob .WriteAll (ctx , filepath .Join (airflow2 .PathForJobDirectory (airflow2 .JobsDir , ns .ID . String () ), "file1.py" ), []byte ("test1" ), nil )
283- _ = inMemBlob .WriteAll (ctx , filepath .Join (airflow2 .PathForJobDirectory (airflow2 .JobsDir , ns .ID . String () ), "file2.json" ), []byte ("test2" ), nil )
286+ _ = inMemBlob .WriteAll (ctx , filepath .Join (airflow2 .PathForJobDirectory (airflow2 .JobsDir , ns .Name ), "file1.py" ), []byte ("test1" ), nil )
287+ _ = inMemBlob .WriteAll (ctx , filepath .Join (airflow2 .PathForJobDirectory (airflow2 .JobsDir , ns .Name ), "file2.json" ), []byte ("test2" ), nil )
284288 _ = inMemBlob .WriteAll (ctx , "bar.py" , []byte ("test3" ), nil )
285289 mockBucket .On ("List" , & blob.ListOptions {
286- Prefix : airflow2 .PathForJobDirectory (airflow2 .JobsDir , ns .ID . String () ),
290+ Prefix : airflow2 .PathForJobDirectory (airflow2 .JobsDir , ns .Name ),
287291 })
288292 defer mockBucket .AssertExpectations (t )
289293
@@ -292,7 +296,7 @@ func TestAirflow2(t *testing.T) {
292296 defer mockBucketFac .AssertExpectations (t )
293297
294298 air := airflow2 .NewScheduler (mockBucketFac , nil , nil )
295- respJobs , err := air .ListJobs (ctx , ns , models.SchedulerListOptions {OnlyName : true })
299+ respJobs , err := air .ListJobs (ctx , ns . Name , ns , models.SchedulerListOptions {OnlyName : true })
296300 assert .Nil (t , err )
297301 assert .Equal (t , 1 , len (respJobs ))
298302 })
@@ -301,21 +305,21 @@ func TestAirflow2(t *testing.T) {
301305 mockBucket := & MockedBucket {
302306 bucket : inMemBlob ,
303307 }
304- _ = inMemBlob .WriteAll (ctx , airflow2 .PathFromJobName (airflow2 .JobsDir , ns .ID . String () , "file1" , airflow2 .JobsExtension ), []byte ("test1" ), nil )
305- _ = inMemBlob .WriteAll (ctx , airflow2 .PathFromJobName (airflow2 .JobsDir , ns .ID . String () , "file2" , airflow2 .JobsExtension ), []byte ("test2" ), nil )
308+ _ = inMemBlob .WriteAll (ctx , airflow2 .PathFromJobName (airflow2 .JobsDir , ns .Name , "file1" , airflow2 .JobsExtension ), []byte ("test1" ), nil )
309+ _ = inMemBlob .WriteAll (ctx , airflow2 .PathFromJobName (airflow2 .JobsDir , ns .Name , "file2" , airflow2 .JobsExtension ), []byte ("test2" ), nil )
306310 mockBucket .On ("List" , & blob.ListOptions {
307- Prefix : airflow2 .PathForJobDirectory (airflow2 .JobsDir , ns .ID . String () ),
311+ Prefix : airflow2 .PathForJobDirectory (airflow2 .JobsDir , ns .Name ),
308312 })
309- mockBucket .On ("ReadAll" , mock .Anything , airflow2 .PathFromJobName (airflow2 .JobsDir , ns .ID . String () , "file1" , airflow2 .JobsExtension ))
310- mockBucket .On ("ReadAll" , mock .Anything , airflow2 .PathFromJobName (airflow2 .JobsDir , ns .ID . String () , "file2" , airflow2 .JobsExtension ))
313+ mockBucket .On ("ReadAll" , mock .Anything , airflow2 .PathFromJobName (airflow2 .JobsDir , ns .Name , "file1" , airflow2 .JobsExtension ))
314+ mockBucket .On ("ReadAll" , mock .Anything , airflow2 .PathFromJobName (airflow2 .JobsDir , ns .Name , "file2" , airflow2 .JobsExtension ))
311315 defer mockBucket .AssertExpectations (t )
312316
313317 mockBucketFac := new (MockedBucketFactory )
314318 mockBucketFac .On ("New" , mock .Anything , proj ).Return (mockBucket , nil )
315319 defer mockBucketFac .AssertExpectations (t )
316320
317321 air := airflow2 .NewScheduler (mockBucketFac , nil , nil )
318- respJobs , err := air .ListJobs (ctx , ns , models.SchedulerListOptions {})
322+ respJobs , err := air .ListJobs (ctx , ns . Name , ns , models.SchedulerListOptions {})
319323 assert .Nil (t , err )
320324 assert .Equal (t , 2 , len (respJobs ))
321325 })
0 commit comments