forked from Azure/azure-sdk-for-net
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Storage] [DataMovement] Added Download File Share Tests and Minor Fi…
…xes (Azure#39206) * Added download tests for file shares * Rerecorded tests * Cleanup
- Loading branch information
1 parent
b122a22
commit 444d632
Showing
8 changed files
with
900 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
...rage/Azure.Storage.DataMovement.Files.Shares/tests/ShareFileStartTransferDownloadTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Azure.Storage.DataMovement.Tests; | ||
using Azure.Storage.Files.Shares; | ||
using Azure.Storage.Files.Shares.Tests; | ||
using Azure.Storage.Test.Shared; | ||
|
||
namespace Azure.Storage.DataMovement.Files.Shares.Tests | ||
{ | ||
[ShareClientTestFixture] | ||
public class ShareFileStartTransferDownloadTests : StartTransferDownloadTestBase< | ||
ShareServiceClient, | ||
ShareClient, | ||
ShareFileClient, | ||
ShareClientOptions, | ||
StorageTestEnvironment> | ||
{ | ||
private const string _fileResourcePrefix = "test-file-"; | ||
private const string _expectedOverwriteExceptionMessage = "Cannot overwrite file."; | ||
|
||
public ShareFileStartTransferDownloadTests( | ||
bool async, | ||
ShareClientOptions.ServiceVersion serviceVersion) | ||
: base(async, _expectedOverwriteExceptionMessage, _fileResourcePrefix, null /* RecordedTestMode.Record /* to re-record */) | ||
{ | ||
ClientBuilder = ClientBuilderExtensions.GetNewShareClientBuilder(Tenants, serviceVersion); | ||
} | ||
|
||
protected override async Task<IDisposingContainer<ShareClient>> GetDisposingContainerAsync(ShareServiceClient service = null, string containerName = null) | ||
=> await ClientBuilder.GetTestShareAsync(service, containerName); | ||
|
||
protected override async Task<ShareFileClient> GetObjectClientAsync( | ||
ShareClient container, | ||
long? objectLength, | ||
string objectName, | ||
bool createObject = false, | ||
ShareClientOptions options = null, | ||
Stream contents = null) | ||
{ | ||
objectName ??= GetNewObjectName(); | ||
if (createObject) | ||
{ | ||
if (!objectLength.HasValue) | ||
{ | ||
throw new InvalidOperationException($"Cannot create share file without size specified."); | ||
} | ||
ShareFileClient fileClient = container.GetRootDirectoryClient().GetFileClient(objectName); | ||
await fileClient.CreateAsync(objectLength.Value); | ||
|
||
if (contents != default && contents.Length > 0) | ||
{ | ||
await fileClient.UploadAsync(contents); | ||
} | ||
|
||
return fileClient; | ||
} | ||
return container.GetRootDirectoryClient().GetFileClient(objectName); | ||
} | ||
|
||
protected override StorageResourceItem GetStorageResourceItem(ShareFileClient objectClient) | ||
=> new ShareFileStorageResource(objectClient); | ||
|
||
protected override Task<Stream> OpenReadAsync(ShareFileClient objectClient) | ||
=> objectClient.OpenReadAsync(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.