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.
[DataMovement] Adding Tests for Recorded File Upload (Add fix Creatin…
…g File at Initial Start) (Azure#39037) * Added Single Share File Upload Tests; Create before putrange * WIP * Removed testbase for startTransfer upload test base; other pr comments
- Loading branch information
1 parent
21f679d
commit 1e83e99
Showing
10 changed files
with
1,046 additions
and
44 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
6 changes: 6 additions & 0 deletions
6
sdk/storage/Azure.Storage.DataMovement.Files.Shares/assets.json
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,6 @@ | ||
{ | ||
"AssetsRepo": "Azure/azure-sdk-assets", | ||
"AssetsRepoPrefixPath": "net", | ||
"TagPrefix": "net/storage/Azure.Storage.DataMovement.Files.Shares", | ||
"Tag": "net/storage/Azure.Storage.DataMovement.Files.Shares_b5e6d0b779" | ||
} |
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
59 changes: 59 additions & 0 deletions
59
sdk/storage/Azure.Storage.DataMovement.Files.Shares/tests/ClientBuilderExtensions.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,59 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using Azure.Storage.Test.Shared; | ||
using Azure.Storage.Files.Shares; | ||
using Azure.Storage.Files.Shares.Tests; | ||
using SharesClientBuilder = Azure.Storage.Test.Shared.ClientBuilder< | ||
Azure.Storage.Files.Shares.ShareServiceClient, | ||
Azure.Storage.Files.Shares.ShareClientOptions>; | ||
|
||
namespace Azure.Storage.DataMovement.Files.Shares.Tests | ||
{ | ||
internal static class ClientBuilderExtensions | ||
{ | ||
public static string GetNewShareName(this SharesClientBuilder clientBuilder) | ||
=> $"test-share-{clientBuilder.Recording.Random.NewGuid()}"; | ||
public static string GetNewDirectoryName(this SharesClientBuilder clientBuilder) | ||
=> $"test-directory-{clientBuilder.Recording.Random.NewGuid()}"; | ||
public static string GetNewNonAsciiDirectoryName(this SharesClientBuilder clientBuilder) | ||
=> $"test-dire¢t Ø®ϒ%3A-{clientBuilder.Recording.Random.NewGuid()}"; | ||
public static string GetNewFileName(this SharesClientBuilder clientBuilder) | ||
=> $"test-file-{clientBuilder.Recording.Random.NewGuid()}"; | ||
public static string GetNewNonAsciiFileName(this SharesClientBuilder clientBuilder) | ||
=> $"test-ƒ¡£€‽%3A-{clientBuilder.Recording.Random.NewGuid()}"; | ||
|
||
/// <summary> | ||
/// Creates a new <see cref="ClientBuilder{TServiceClient, TServiceClientOptions}"/> | ||
/// setup to generate <see cref="BlobServiceClient"/>s. | ||
/// </summary> | ||
/// <param name="tenants"><see cref="TenantConfigurationBuilder"/> powering this client builder.</param> | ||
/// <param name="serviceVersion">Service version for clients to target.</param> | ||
public static SharesClientBuilder GetNewShareClientBuilder(TenantConfigurationBuilder tenants, ShareClientOptions.ServiceVersion serviceVersion) | ||
=> new SharesClientBuilder( | ||
ServiceEndpoint.File, | ||
tenants, | ||
(uri, clientOptions) => new ShareServiceClient(uri, clientOptions), | ||
(uri, sharedKeyCredential, clientOptions) => new ShareServiceClient(uri, sharedKeyCredential, clientOptions), | ||
(uri, tokenCredential, clientOptions) => new ShareServiceClient(uri, tokenCredential, clientOptions), | ||
(uri, azureSasCredential, clientOptions) => new ShareServiceClient(uri, azureSasCredential, clientOptions), | ||
() => new ShareClientOptions(serviceVersion)); | ||
|
||
public static async Task<DisposingShare> GetTestShareAsync( | ||
this SharesClientBuilder clientBuilder, | ||
ShareServiceClient service = default, | ||
string shareName = default, | ||
IDictionary<string, string> metadata = default, | ||
ShareClientOptions options = default) | ||
{ | ||
service ??= clientBuilder.GetServiceClientFromSharedKeyConfig(clientBuilder.Tenants.TestConfigDefault, options); | ||
metadata ??= new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); | ||
shareName ??= clientBuilder.GetNewShareName(); | ||
ShareClient share = clientBuilder.AzureCoreRecordedTestBase.InstrumentClient(service.GetShareClient(shareName)); | ||
return await DisposingShare.CreateAsync(share, metadata); | ||
} | ||
} | ||
} |
Oops, something went wrong.