Skip to content

Commit

Permalink
add tests exercising all aliases, fix storagelocation alias (#6094)
Browse files Browse the repository at this point in the history
  • Loading branch information
scbedd authored May 4, 2023
1 parent 31ac851 commit 20ebdab
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 5 deletions.
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

0 comments on commit 20ebdab

Please sign in to comment.