From bd8bb33ea0819c5886ded26399063424766fc68b Mon Sep 17 00:00:00 2001 From: Shubh Sohal Date: Mon, 23 Jun 2025 14:08:09 -0400 Subject: [PATCH] Adding tests to verify cloud patterns --- test/tZarrCreate.m | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/test/tZarrCreate.m b/test/tZarrCreate.m index e361947..73f4bf9 100644 --- a/test/tZarrCreate.m +++ b/test/tZarrCreate.m @@ -4,7 +4,6 @@ % Copyright 2025 The MathWorks, Inc. methods(Test) - function createDefaultArray(testcase) % Verify that zarrcreate correctly creates a Zarr array with % all default properties @@ -25,7 +24,6 @@ function createDefaultArray(testcase) actInfo = zarrinfo(testcase.ArrPathWrite); testcase.verifyEqual(actInfo, expInfo,... 'Failed to verify creating Zarr array with default properties'); - end function createIntermediateZgroups(testcase) @@ -64,6 +62,27 @@ function createArrayRelativePath(testcase) testcase.verifyEqual(arrInfo.node_type,'array','Unexpected Zarr array node type'); end + function verifySupportedCloudPatterns(testcase) + % Verify that the bucket name and the array path can be + % extracted successfully if a cloud path is used as an input. + + % This list contains path pattern currently supported by Zarr + % in MATLAB. Any invalid path not matching any of these + % patterns will result in an error. + inpPath = {'https://mybucket.s3.us-west-2.amazonaws.com/path/to/myZarrFile', ... + 'https://mybucket.s3.amazonaws.com/path/to/myZarrFile', ... + 'https://mybucket.s3.custom-endpoint.org/path/to/myZarrFile', ... + 'https://s3.amazonaws.com/mybucket/path/to/myZarrFile', ... + 'https://s3.eu-central-1.example.edu/mybucket/path/to/myZarrFile', ... + 's3://mybucket/path/to/myZarrFile'}; + + for i = 1:length(inpPath) + [bucketName, objectPath] = Zarr.extractS3BucketNameAndPath(inpPath{i}); + testcase.verifyEqual(bucketName, 'mybucket', ['Bucket name extraction failed for ' inpPath{i}]); + testcase.verifyEqual(objectPath, 'path/to/myZarrFile', ['Object path extraction failed for ' inpPath{i}]); + end + end + function invalidFilePath(testcase) % Verify error when an invalid file path is used as an input to % zarrcreate function.