diff --git a/tests/functions/S3ListBucket.cfc b/tests/functions/S3ListBucket.cfc index fcdbb9f..590d5e7 100644 --- a/tests/functions/S3ListBucket.cfc +++ b/tests/functions/S3ListBucket.cfc @@ -4,21 +4,25 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="s3" { it(title="check region with blackbaze",skip=Util::isBackBlazeNotSupported(), body = function( currentSpec ) { testit(Util::getBackBlazeCredentials()); testUDF(Util::getBackBlazeCredentials()); + testCFC(Util::getBackBlazeCredentials()); }); it(title="check with amazon",skip=Util::isAWSNotSupported(), body = function( currentSpec ) { testit(Util::getAWSCredentials()); testUDF(Util::getAWSCredentials()); + testCFC(Util::getAWSCredentials()); }); it(title="check with wasabi",skip=Util::isWasabiNotSupported(), body = function( currentSpec ) { testit(Util::getWasabiCredentials()); testUDF(Util::getWasabiCredentials()); + testCFC(Util::getWasabiCredentials()); }); it(title="check with google",skip=Util::isGoogleNotSupported(), body = function( currentSpec ) { testit(Util::getGoogleCredentials()); testUDF(Util::getGoogleCredentials()); + testCFC(Util::getGoogleCredentials()); }); }); @@ -55,6 +59,50 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="s3" { } } + private function testCFC(cred) { + try { + // create variables + var bucketName=cred.PREFIX&"-list-bucket:"&listFirst(replace(server.lucee.version,".","","all"),"-"); + var objectNames=["sub/test1.txt","sub/test2.txt","sub/test3.txt","sub/test4.txt","sub/test5.txt"]; + + // create empty bucket + Util::deleteIfExists(cred,bucketName); + S3CreateBucket( + bucketName:bucketName, + accessKeyId:cred.ACCESS_KEY_ID, secretAccessKey:cred.SECRET_KEY, host:(isNull(cred.HOST)?nullvalue():cred.HOST)); + + // create objects + loop array=objectNames item="local.objectName" { + // 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 listener=new S3ListBucketListener(); + S3ListBucket( + bucketName:bucketName, + listener:listener, + blockfactor:3, + accessKeyId:cred.ACCESS_KEY_ID, + secretAccessKey:cred.SECRET_KEY, + host:(isNull(cred.HOST)?nullvalue():cred.HOST) + ); + assertEquals("->3;2;<-", listener.getData()); + } + catch(e) { + if(!findNoCase("Transaction cap exceeded", e.message) ) throw e; + } + finally { + Util::deleteBucketEL(cred,bucketName); + } + } + private function testUDF(cred) { try { // create variables diff --git a/tests/functions/S3ListBucketListener.cfc b/tests/functions/S3ListBucketListener.cfc new file mode 100644 index 0000000..9b17533 --- /dev/null +++ b/tests/functions/S3ListBucketListener.cfc @@ -0,0 +1,18 @@ +component { + variables.res=""; + + function before(){ + variables.res&="-->"; + } + function after(){ + variables.res&="<--"; + } + + function invoke(data){ + variables.res&=data.recordcount&";"; + } + + function getData() { + return variables.res; + } +} \ No newline at end of file