Skip to content

Commit e504a8b

Browse files
Add error code in azfile error codes.go (Azure#23872)
* add error code in azfile error codes.go * added test for limit exceeded
1 parent 3ea9f0c commit e504a8b

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

sdk/storage/azfile/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "go",
44
"TagPrefix": "go/storage/azfile",
5-
"Tag": "go/storage/azfile_c4deb17f89"
5+
"Tag": "go/storage/azfile_5bfa72cc2c"
66
}

sdk/storage/azfile/fileerror/error_codes.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ const (
9191
ShareDisabled Code = "ShareDisabled"
9292
ShareHasSnapshots Code = "ShareHasSnapshots"
9393
ShareNotFound Code = "ShareNotFound"
94+
ShareSizeLimitReached Code = "ShareSizeLimitReached"
9495
ShareSnapshotCountExceeded Code = "ShareSnapshotCountExceeded"
9596
ShareSnapshotInProgress Code = "ShareSnapshotInProgress"
9697
ShareSnapshotOperationNotSupported Code = "ShareSnapshotOperationNotSupported"

sdk/storage/azfile/share/client_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,36 @@ func (s *ShareRecordedTestsSuite) TestShareCreateNilMetadata() {
298298
_require.Len(response.Metadata, 0)
299299
}
300300

301+
func (s *ShareRecordedTestsSuite) TestShareSizeLimitReached() {
302+
_require := require.New(s.T())
303+
testName := s.T().Name()
304+
305+
svcClient, err := testcommon.GetServiceClient(s.T(), testcommon.TestAccountDefault, nil)
306+
_require.NoError(err)
307+
308+
shareName := testcommon.GenerateShareName(testName)
309+
shareClient := svcClient.NewShareClient(shareName)
310+
311+
quotaInGB := int32(1) // Set a 1 GB quota
312+
_, err = shareClient.Create(context.Background(), &service.CreateShareOptions{
313+
Quota: &quotaInGB,
314+
})
315+
defer testcommon.DeleteShare(context.Background(), _require, shareClient)
316+
_require.NoError(err)
317+
318+
// Attempt to exceed the share's quota
319+
dirClient := shareClient.NewDirectoryClient("testdir")
320+
_, err = dirClient.Create(context.Background(), nil)
321+
_require.NoError(err)
322+
323+
fileClient := dirClient.NewFileClient("largefile")
324+
fileSize := int64(2 * 1024 * 1024 * 1024) // 2 GB file to exceed 1 GB quota
325+
_, err = fileClient.Create(context.Background(), fileSize, nil)
326+
_require.Error(err)
327+
328+
testcommon.ValidateFileErrorCode(_require, err, fileerror.ShareSizeLimitReached)
329+
}
330+
301331
func (s *ShareRecordedTestsSuite) TestShareCreateWithSnapshotVirtualDirectoryAccess() {
302332
_require := require.New(s.T())
303333
testName := s.T().Name()

0 commit comments

Comments
 (0)