Skip to content

Commit b07646b

Browse files
committed
test(storage): fix bucket lock system tests
1 parent 6f9712f commit b07646b

5 files changed

Lines changed: 11 additions & 6 deletions

File tree

storage/releaseEventBasedHold.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
function main(
2626
bucketName = 'my-bucket',
2727
fileName = 'test.txt',
28-
metagenerationMatchPrecondition = 0
28+
metagenerationMatchPrecondition = null
2929
) {
3030
// [START storage_release_event_based_hold]
3131
/**

storage/releaseTemporaryHold.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
function main(
2626
bucketName = 'my-bucket',
2727
fileName = 'test.txt',
28-
metagenerationMatchPrecondition = 0
28+
metagenerationMatchPrecondition = null
2929
) {
3030
// [START storage_release_temporary_hold]
3131
/**

storage/setEventBasedHold.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
function main(
2626
bucketName = 'my-bucket',
2727
fileName = 'test.txt',
28-
metagenerationMatchPrecondition = 0
28+
metagenerationMatchPrecondition = null
2929
) {
3030
// [START storage_set_event_based_hold]
3131
/**

storage/setTemporaryHold.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
function main(
2626
bucketName = 'my-bucket',
2727
fileName = 'test.txt',
28-
metagenerationMatchPrecondition = 0
28+
metagenerationMatchPrecondition = null
2929
) {
3030
// [START storage_set_temporary_hold]
3131
/**

storage/system-test/bucketLock.test.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,20 @@ before(async () => {
3737
});
3838

3939
after(async () => {
40+
// The last test locks a retention policy. Wait for the retention
41+
// period (5s) to pass before attempting to delete objects and the bucket.
42+
// A small buffer is added to account for timing inaccuracies.
43+
await new Promise(resolve => setTimeout(resolve, 6000));
44+
4045
try {
4146
await bucket.deleteFiles({force: true});
4247
} catch (err) {
43-
// ignore error
48+
console.error('Failed to delete files during cleanup:', err);
4449
}
4550
try {
4651
await bucket.delete();
4752
} catch (err) {
48-
// ignore error
53+
console.error('Failed to delete bucket during cleanup:', err);
4954
}
5055
});
5156

0 commit comments

Comments
 (0)