@@ -382,6 +382,85 @@ func TestBucketReconciler_reconcileMinioSource(t *testing.T) {
382
382
* conditions .TrueCondition (sourcev1 .ArtifactOutdatedCondition , "NewRevision" , "New upstream revision '94992ae8fb8300723e970e304ea3414266cb414e364ba3f570bb09069f883100'" ),
383
383
},
384
384
},
385
+ {
386
+ name : "spec.ignore overrides .sourceignore" ,
387
+ bucketName : "dummy" ,
388
+ beforeFunc : func (obj * sourcev1.Bucket ) {
389
+ ignore := "included/file.txt"
390
+ obj .Spec .Ignore = & ignore
391
+ },
392
+ bucketObjects : []* s3MockObject {
393
+ {
394
+ Key : ".sourceignore" ,
395
+ Content : []byte ("ignored/file.txt" ),
396
+ ContentType : "text/plain" ,
397
+ LastModified : time .Now (),
398
+ },
399
+ {
400
+ Key : "ignored/file.txt" ,
401
+ Content : []byte ("ignored/file.txt" ),
402
+ ContentType : "text/plain" ,
403
+ LastModified : time .Now (),
404
+ },
405
+ {
406
+ Key : "included/file.txt" ,
407
+ Content : []byte ("included/file.txt" ),
408
+ ContentType : "text/plain" ,
409
+ LastModified : time .Now (),
410
+ },
411
+ },
412
+ assertArtifact : sourcev1.Artifact {
413
+ Path : "bucket/test-bucket/e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.tar.gz" ,
414
+ Revision : "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" ,
415
+ },
416
+ assertConditions : []metav1.Condition {
417
+ * conditions .TrueCondition (sourcev1 .ArtifactOutdatedCondition , "NewRevision" , "New upstream revision 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'" ),
418
+ },
419
+ },
420
+ {
421
+ name : "up-to-date artifact" ,
422
+ bucketName : "dummy" ,
423
+ beforeFunc : func (obj * sourcev1.Bucket ) {
424
+ obj .Status .Artifact = & sourcev1.Artifact {
425
+ Revision : "f0467900d3cede8323f3e61a1467f7cd370d1c0d942ff990a1a7be1eb1a231e8" ,
426
+ }
427
+ },
428
+ bucketObjects : []* s3MockObject {
429
+ {
430
+ Key : "test.txt" ,
431
+ Content : []byte ("test" ),
432
+ ContentType : "text/plain" ,
433
+ LastModified : time .Now (),
434
+ },
435
+ },
436
+ assertArtifact : sourcev1.Artifact {
437
+ Path : "bucket/test-bucket/f0467900d3cede8323f3e61a1467f7cd370d1c0d942ff990a1a7be1eb1a231e8.tar.gz" ,
438
+ Revision : "f0467900d3cede8323f3e61a1467f7cd370d1c0d942ff990a1a7be1eb1a231e8" ,
439
+ },
440
+ assertConditions : []metav1.Condition {},
441
+ },
442
+ {
443
+ name : "Removes FetchFailedCondition after reconciling source" ,
444
+ bucketName : "dummy" ,
445
+ beforeFunc : func (obj * sourcev1.Bucket ) {
446
+ conditions .MarkTrue (obj , sourcev1 .FetchFailedCondition , sourcev1 .BucketOperationFailedReason , "Failed to read test file" )
447
+ },
448
+ bucketObjects : []* s3MockObject {
449
+ {
450
+ Key : "test.txt" ,
451
+ Content : []byte ("test" ),
452
+ ContentType : "text/plain" ,
453
+ LastModified : time .Now (),
454
+ },
455
+ },
456
+ assertArtifact : sourcev1.Artifact {
457
+ Path : "bucket/test-bucket/f0467900d3cede8323f3e61a1467f7cd370d1c0d942ff990a1a7be1eb1a231e8.tar.gz" ,
458
+ Revision : "f0467900d3cede8323f3e61a1467f7cd370d1c0d942ff990a1a7be1eb1a231e8" ,
459
+ },
460
+ assertConditions : []metav1.Condition {
461
+ * conditions .TrueCondition (sourcev1 .ArtifactOutdatedCondition , "NewRevision" , "New upstream revision 'f0467900d3cede8323f3e61a1467f7cd370d1c0d942ff990a1a7be1eb1a231e8'" ),
462
+ },
463
+ },
385
464
}
386
465
for _ , tt := range tests {
387
466
t .Run (tt .name , func (t * testing.T ) {
0 commit comments