Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve broken storageLocation short alias #6094

Merged
merged 1 commit into from
May 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ namespace Azure.Sdk.Tools.TestProxy.Tests
{
public class InvocationTests
{


[Theory]
[InlineData("start", "-i", "-d")]
[InlineData("start")]
Expand Down Expand Up @@ -51,6 +49,63 @@ public async Task TestBasicServerInvocations(params string[] input)
}
}

[Theory]
[InlineData("push", "-a", "path/to/assets.json")]
[InlineData("push", "--assets-json-path", "path/to/assets.json")]
public async Task TestAssetsOptions(params string[] input)
{
var obj = new object();
var rootCommand = OptionsGenerator.GenerateCommandLineOptions((DefaultOptions) =>
{
obj = DefaultOptions;

return Task.CompletedTask;
});
var exitCode = await rootCommand.InvokeAsync(input);

Assert.Equal(0, exitCode);
Assert.True(obj is PushOptions);
Assert.Equal("path/to/assets.json", ((PushOptions)obj).AssetsJsonPath);
}

[Theory]
[InlineData("start", "-l", "C:/repo/sdk-for-python")]
[InlineData("start", "--storage-location", "C:/repo/sdk-for-python")]
public async Task TestStorageLocationOptions(params string[] input)
{
var obj = new object();
var rootCommand = OptionsGenerator.GenerateCommandLineOptions((DefaultOptions) =>
{
obj = DefaultOptions;

return Task.CompletedTask;
});
var exitCode = await rootCommand.InvokeAsync(input);

Assert.Equal(0, exitCode);
Assert.True(obj is StartOptions);
Assert.Equal("C:/repo/sdk-for-python", ((StartOptions)obj).StorageLocation);
}

[Theory]
[InlineData("push", "-a", "path/to/assets.json", "-p", "BlobStore")]
[InlineData("push", "-a", "path/to/assets.json", "--storage-plugin", "BlobStore")]
public async Task TestStoragePluginOptions(params string[] input)
{
var obj = new object();
var rootCommand = OptionsGenerator.GenerateCommandLineOptions((DefaultOptions) =>
{
obj = DefaultOptions;

return Task.CompletedTask;
});
var exitCode = await rootCommand.InvokeAsync(input);

Assert.Equal(0, exitCode);
Assert.True(obj is PushOptions);
Assert.Equal("BlobStore", ((PushOptions)obj).StoragePlugin);
}

[Fact]
public async Task TestServerInvocationsHonorUnmatched()
{
Expand Down Expand Up @@ -168,7 +223,6 @@ public async Task TestInvalidVerbCombinations(params string[] input)

[Theory]
[InlineData("push", "-a", "path/to/assets.json")]

public async Task TestPushOptions(params string[] input)
{
var output = new StringWriter();
Expand Down Expand Up @@ -211,6 +265,7 @@ public async Task TestRestoreOptions(params string[] input)
[Theory]
[InlineData("reset", "-a", "path/to/assets.json")]
[InlineData("reset", "-y", "-a", "path/to/assets.json")]
[InlineData("reset", "--yes", "-a", "path/to/assets.json")]
public async Task TestResetOptions(params string[] input)
{
var output = new StringWriter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ public static RootCommand GenerateCommandLineOptions(Func<DefaultOptions, Task>
name: "--storage-location",
description: "The path to the target local git repo. If not provided as an argument, Environment variable TEST_PROXY_FOLDER will be consumed. Lacking both, the current working directory will be utilized.",
getDefaultValue: () => null);
storageLocationOption.AddAlias("-f");
storageLocationOption.AddAlias("-l");

var storagePluginOption = new Option<string>(
name: "--storage-plugin",
description: "The plugin for the selected storage, default is Git storage is GitStore. (Currently the only option)",
getDefaultValue: () => "GitStore");
storagePluginOption.AddAlias("-l");
storagePluginOption.AddAlias("-p");

var assetsJsonPathOption = new Option<string>(
name: "--assets-json-path",
Expand Down