Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Extend testing
  • Loading branch information
adreed-msft committed Sep 1, 2023
commit 6b3121f7c2ecb26b060b2e20c56bd98de0cb9e04
34 changes: 31 additions & 3 deletions sdk/storage/azdatalake/directory/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,27 +75,55 @@ func (d *UnrecordedTestSuite) TestDirNewSubdirectoryClient() {
fsName := testcommon.GenerateFileSystemName(testName)
fsClient := svcClient.NewFileSystemClient(fsName)

_, err = fsClient.Create(context.Background(), nil)
_require.NoError(err)

defer testcommon.DeleteFileSystem(context.Background(), _require, fsClient) // clean up

dirName := testcommon.GenerateDirName(testName)
dirClient := fsClient.NewDirectoryClient(dirName)

_, err = dirClient.Create(context.Background(), nil)
_require.NoError(err)

subdirName := "subdir"
subdirClient, err := dirClient.NewSubdirectoryClient(subdirName)
_require.NoError(err)

correctDirURL := fmt.Sprintf("https://%s.dfs.core.windows.net/%s/%s/%s", accountName, fsName, dirName, subdirName)
_require.Equal(correctDirURL, subdirClient.DFSURL())

perm := "0766"
perm := "r-xr-x---"

_, err = dirClient.Create(context.Background(), &directory.CreateOptions{
_, err = subdirClient.Create(context.Background(), &directory.CreateOptions{
Permissions: &perm,
})
_require.NoError(err)

resp, err := dirClient.GetProperties(context.Background(), nil)
resp, err := subdirClient.GetProperties(context.Background(), nil)
_require.NoError(err)
_require.NotNil(resp.Permissions)
_require.Equal(perm, *resp.Permissions)

// Create a file under the new directory just to make sure we're not secretly targeting the parent
fileName := "asdf.txt"
subdirFileClient, err := subdirClient.NewFileClient(fileName)
_require.NoError(err)

_, err = subdirFileClient.Create(context.Background(), nil)
_require.NoError(err)

fileContents := []byte("foobar")
err = subdirFileClient.UploadBuffer(context.Background(), fileContents, nil)
_require.NoError(err)

// check for the file at the parent directory
dirFileClient, err := dirClient.NewFileClient(fileName)
_require.NoError(err)

_, err = dirFileClient.GetProperties(context.Background(), nil)
_require.Error(err) // we should get back a 404
_require.True(datalakeerror.HasCode(err, datalakeerror.PathNotFound))
}

func (s *RecordedTestSuite) TestCreateDirAndDeleteWithConnectionString() {
Expand Down