Skip to content

Commit

Permalink
added test for limit exceeded
Browse files Browse the repository at this point in the history
  • Loading branch information
tanyasethi-msft committed Dec 17, 2024
1 parent 3c72360 commit 855daa0
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sdk/storage/azfile/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
30 changes: 30 additions & 0 deletions sdk/storage/azfile/share/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: &quotaInGB,
})
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()
Expand Down

0 comments on commit 855daa0

Please sign in to comment.