From 855daa06504dcfb2d03295054af6813f28d9448f Mon Sep 17 00:00:00 2001 From: tanyasethi-msft Date: Tue, 17 Dec 2024 14:56:07 +0530 Subject: [PATCH] added test for limit exceeded --- sdk/storage/azfile/assets.json | 2 +- sdk/storage/azfile/share/client_test.go | 30 +++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/sdk/storage/azfile/assets.json b/sdk/storage/azfile/assets.json index add86cbfe23a..36bc40da6a09 100644 --- a/sdk/storage/azfile/assets.json +++ b/sdk/storage/azfile/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "go", "TagPrefix": "go/storage/azfile", - "Tag": "go/storage/azfile_c4deb17f89" + "Tag": "go/storage/azfile_5bfa72cc2c" } diff --git a/sdk/storage/azfile/share/client_test.go b/sdk/storage/azfile/share/client_test.go index 3043f3718b4d..230b86953e81 100644 --- a/sdk/storage/azfile/share/client_test.go +++ b/sdk/storage/azfile/share/client_test.go @@ -298,6 +298,36 @@ func (s *ShareRecordedTestsSuite) TestShareCreateNilMetadata() { _require.Len(response.Metadata, 0) } +func (s *ShareRecordedTestsSuite) TestShareSizeLimitReached() { + _require := require.New(s.T()) + testName := s.T().Name() + + svcClient, err := testcommon.GetServiceClient(s.T(), testcommon.TestAccountDefault, nil) + _require.NoError(err) + + shareName := testcommon.GenerateShareName(testName) + shareClient := svcClient.NewShareClient(shareName) + + quotaInGB := int32(1) // Set a 1 GB quota + _, err = shareClient.Create(context.Background(), &service.CreateShareOptions{ + Quota: "aInGB, + }) + defer testcommon.DeleteShare(context.Background(), _require, shareClient) + _require.NoError(err) + + // Attempt to exceed the share's quota + dirClient := shareClient.NewDirectoryClient("testdir") + _, err = dirClient.Create(context.Background(), nil) + _require.NoError(err) + + fileClient := dirClient.NewFileClient("largefile") + fileSize := int64(2 * 1024 * 1024 * 1024) // 2 GB file to exceed 1 GB quota + _, err = fileClient.Create(context.Background(), fileSize, nil) + _require.Error(err) + + testcommon.ValidateFileErrorCode(_require, err, fileerror.ShareSizeLimitReached) +} + func (s *ShareRecordedTestsSuite) TestShareCreateWithSnapshotVirtualDirectoryAccess() { _require := require.New(s.T()) testName := s.T().Name()