From 20ebdabcabc70ae13b2778935982695641cfb61e Mon Sep 17 00:00:00 2001 From: Scott Beddall <45376673+scbedd@users.noreply.github.com> Date: Wed, 3 May 2023 19:17:51 -0700 Subject: [PATCH] add tests exercising all aliases, fix storagelocation alias (#6094) --- .../InvocationTests.cs | 61 ++++++++++++++++++- .../CommandOptions/OptionsGenerator.cs | 4 +- 2 files changed, 60 insertions(+), 5 deletions(-) diff --git a/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/InvocationTests.cs b/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/InvocationTests.cs index 051d2a55832..71964c7bcb6 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/InvocationTests.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/InvocationTests.cs @@ -10,8 +10,6 @@ namespace Azure.Sdk.Tools.TestProxy.Tests { public class InvocationTests { - - [Theory] [InlineData("start", "-i", "-d")] [InlineData("start")] @@ -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() { @@ -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(); @@ -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(); diff --git a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/CommandOptions/OptionsGenerator.cs b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/CommandOptions/OptionsGenerator.cs index 78cdea9329a..e5a119c4618 100644 --- a/tools/test-proxy/Azure.Sdk.Tools.TestProxy/CommandOptions/OptionsGenerator.cs +++ b/tools/test-proxy/Azure.Sdk.Tools.TestProxy/CommandOptions/OptionsGenerator.cs @@ -15,13 +15,13 @@ public static RootCommand GenerateCommandLineOptions(Func 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( 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( name: "--assets-json-path",