2024-03-17 12:56:37 +00:00
|
|
|
using System.CommandLine;
|
2024-03-27 20:50:53 +00:00
|
|
|
using Velopack.Vpk.Commands.Deployment;
|
2024-03-17 12:56:37 +00:00
|
|
|
|
|
|
|
|
namespace Velopack.CommandLine.Tests.Commands;
|
|
|
|
|
|
|
|
|
|
public abstract class AzureCommandTests<T> : BaseCommandTests<T>
|
|
|
|
|
where T : AzureBaseCommand, new()
|
|
|
|
|
{
|
2025-07-25 23:24:16 -04:00
|
|
|
protected override string GetRequiredDefaultOptions()
|
|
|
|
|
{
|
|
|
|
|
return "--account \"test-account\" --key \"test-key\" --container \"test-container\" ";
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-17 12:56:37 +00:00
|
|
|
[Fact]
|
|
|
|
|
public void Command_WithRequiredEndpointOptions_ParsesValue()
|
|
|
|
|
{
|
|
|
|
|
AzureBaseCommand command = new T();
|
|
|
|
|
|
|
|
|
|
string cli = $"--account \"account-name\" --key \"shhhh\" --endpoint \"https://endpoint\" --container \"mycontainer\"";
|
|
|
|
|
ParseResult parseResult = command.ParseAndApply(cli);
|
|
|
|
|
|
|
|
|
|
Assert.Empty(parseResult.Errors);
|
|
|
|
|
Assert.Equal("account-name", command.Account);
|
|
|
|
|
Assert.Equal("shhhh", command.Key);
|
|
|
|
|
Assert.Equal("https://endpoint/", command.Endpoint);
|
2024-03-28 09:43:27 +00:00
|
|
|
Assert.Equal("mycontainer", command.Container);
|
2024-03-17 12:56:37 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class AzureDownloadCommandTests : AzureCommandTests<AzureDownloadCommand>
|
2025-07-25 23:24:16 -04:00
|
|
|
{
|
|
|
|
|
[Fact]
|
|
|
|
|
public void Folder_WithPath_ParsesValue()
|
|
|
|
|
{
|
|
|
|
|
var command = new AzureDownloadCommand();
|
|
|
|
|
|
2025-09-24 23:56:33 +01:00
|
|
|
string cli = GetRequiredDefaultOptions() + " --prefix \"releases/v1\"";
|
2025-07-25 23:24:16 -04:00
|
|
|
ParseResult parseResult = command.ParseAndApply(cli);
|
|
|
|
|
|
2025-09-24 23:56:33 +01:00
|
|
|
Assert.Equal("releases/v1", command.Prefix);
|
2025-07-25 23:24:16 -04:00
|
|
|
}
|
|
|
|
|
}
|
2024-03-17 12:56:37 +00:00
|
|
|
|
|
|
|
|
public class AzureUploadCommandTests : AzureCommandTests<AzureUploadCommand>
|
|
|
|
|
{
|
|
|
|
|
public override bool ShouldBeNonEmptyReleaseDir => true;
|
2025-07-25 23:24:16 -04:00
|
|
|
|
|
|
|
|
protected override string GetRequiredDefaultOptions()
|
|
|
|
|
{
|
|
|
|
|
return base.GetRequiredDefaultOptions() + "--releaseDir \"./releases\" ";
|
|
|
|
|
}
|
2024-03-17 12:56:37 +00:00
|
|
|
|
2025-07-25 23:24:16 -04:00
|
|
|
[Fact]
|
|
|
|
|
public void Folder_WithPath_ParsesValue()
|
|
|
|
|
{
|
|
|
|
|
var command = new AzureUploadCommand();
|
2024-03-17 12:56:37 +00:00
|
|
|
|
2025-09-24 23:56:33 +01:00
|
|
|
string cli = GetRequiredDefaultOptions() + " --prefix \"releases/v1\"";
|
2025-07-25 23:24:16 -04:00
|
|
|
ParseResult parseResult = command.ParseAndApply(cli);
|
|
|
|
|
|
2025-09-24 23:56:33 +01:00
|
|
|
Assert.Equal("releases/v1", command.Prefix);
|
2025-07-25 23:24:16 -04:00
|
|
|
}
|
2024-03-17 12:56:37 +00:00
|
|
|
|
|
|
|
|
}
|