File tree 2 files changed +39
-1
lines changed 2 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -105,7 +105,7 @@ export interface AddLifecycleRuleOptions {
105
105
106
106
export interface LifecycleRule {
107
107
action : { type : string ; storageClass ?: string } | string ;
108
- condition : { [ key : string ] : boolean | Date | number | string } ;
108
+ condition : { [ key : string ] : boolean | Date | number | string | string [ ] } ;
109
109
storageClass ?: string ;
110
110
}
111
111
Original file line number Diff line number Diff line change @@ -1397,6 +1397,44 @@ describe('storage', () => {
1397
1397
) ;
1398
1398
} ) ;
1399
1399
1400
+ it ( 'should add a prefix rule' , async ( ) => {
1401
+ await bucket . addLifecycleRule ( {
1402
+ action : 'delete' ,
1403
+ condition : {
1404
+ matchesPrefix : [ TESTS_PREFIX ] ,
1405
+ } ,
1406
+ } ) ;
1407
+
1408
+ assert (
1409
+ bucket . metadata . lifecycle . rule . some (
1410
+ ( rule : LifecycleRule ) =>
1411
+ typeof rule . action === 'object' &&
1412
+ rule . action . type === 'Delete' &&
1413
+ typeof rule . condition . matchesPrefix === 'object' &&
1414
+ ( rule . condition . matchesPrefix as string [ ] ) . length === 1 &&
1415
+ Array . isArray ( rule . condition . matchesPrefix )
1416
+ )
1417
+ ) ;
1418
+ } ) ;
1419
+
1420
+ it ( 'should add a suffix rule' , async ( ) => {
1421
+ await bucket . addLifecycleRule ( {
1422
+ action : 'delete' ,
1423
+ condition : {
1424
+ matchesSuffix : [ TESTS_PREFIX , 'test_suffix' ] ,
1425
+ } ,
1426
+ } ) ;
1427
+
1428
+ assert (
1429
+ bucket . metadata . lifecycle . rule . some (
1430
+ ( rule : LifecycleRule ) =>
1431
+ typeof rule . action === 'object' &&
1432
+ rule . action . type === 'Delete' &&
1433
+ Array . isArray ( rule . condition . matchesPrefix )
1434
+ )
1435
+ ) ;
1436
+ } ) ;
1437
+
1400
1438
it ( 'should convert a rule with createdBefore to a date in string' , done => {
1401
1439
bucket . addLifecycleRule (
1402
1440
{
You can’t perform that action at this time.
0 commit comments