Skip to content

Commit

Permalink
add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeloffner committed Sep 4, 2023
1 parent 599a3cb commit bb558e0
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions tests/functions/S3ClearBucket.cfc
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
component extends="org.lucee.cfml.test.LuceeTestCase" labels="s3" {
function run( testResults , testBox ) {
describe( title="Test suite for S3ClearBucket()", body=function() {
it(title="check region with blackbaze",skip=Util::isBackBlazeNotSupported(), body = function( currentSpec ) {
testit(Util::getBackBlazeCredentials());
});

it(title="check with amazon",skip=Util::isAWSNotSupported(), body = function( currentSpec ) {
testit(Util::getAWSCredentials());
});

it(title="check with wasabi",skip=Util::isWasabiNotSupported(), body = function( currentSpec ) {
testit(Util::getWasabiCredentials());
});

it(title="check with google",skip=Util::isGoogleNotSupported(), body = function( currentSpec ) {
testit(Util::getGoogleCredentials());
});

});
}


private function testit(cred) {
try {
// create variables
var bucketName=cred.PREFIX&"-clear-bucket";
var objectName="sub/test.txt";


// create source bucket
if(!S3Exists(
bucketName:bucketName, objectName:objectName,
accessKeyId:cred.ACCESS_KEY_ID, secretAccessKey:cred.SECRET_KEY, host:(isNull(cred.HOST)?nullvalue():cred.HOST))) {
S3Write(
value:"Susi Sorglos",
bucketName:bucketName, objectName:objectName,
accessKeyId:cred.ACCESS_KEY_ID, secretAccessKey:cred.SECRET_KEY, host:(isNull(cred.HOST)?nullvalue():cred.HOST));
}

var kids=S3ListBucket(bucketName:bucketName, accessKeyId:cred.ACCESS_KEY_ID, secretAccessKey:cred.SECRET_KEY,host:(isNull(cred.HOST)?nullvalue():cred.HOST));
assertTrue(kids.recordcount>0);

S3ClearBucket(bucketName:bucketName, accessKeyId:cred.ACCESS_KEY_ID, secretAccessKey:cred.SECRET_KEY,host:(isNull(cred.HOST)?nullvalue():cred.HOST));

var kids=S3ListBucket(bucketName:bucketName, accessKeyId:cred.ACCESS_KEY_ID, secretAccessKey:cred.SECRET_KEY,host:(isNull(cred.HOST)?nullvalue():cred.HOST));
assertTrue(kids.recordcount==0);
}
finally {
Util::deleteBucketEL(cred,bucketName);
}
}


private function doFind(value){
return value EQ "world";
}

}

0 comments on commit bb558e0

Please sign in to comment.