2023-12-15 17:27:33 +00:00
|
|
|
|
2023-12-17 17:00:38 +00:00
|
|
|
using System.CommandLine;
|
2024-03-27 20:50:53 +00:00
|
|
|
using Velopack.Vpk.Commands.Deployment;
|
2023-12-17 17:00:38 +00:00
|
|
|
|
2023-12-31 11:09:44 +00:00
|
|
|
namespace Velopack.CommandLine.Tests.Commands;
|
2022-09-24 00:05:25 -07:00
|
|
|
|
2023-12-15 17:27:33 +00:00
|
|
|
public class HttpDownloadCommandTests : BaseCommandTests<HttpDownloadCommand>
|
2022-09-24 00:05:25 -07:00
|
|
|
{
|
2023-12-15 17:27:33 +00:00
|
|
|
[Fact]
|
|
|
|
|
public void Url_WithUrl_ParsesValue()
|
2022-09-24 00:05:25 -07:00
|
|
|
{
|
2023-12-15 17:27:33 +00:00
|
|
|
var command = new HttpDownloadCommand();
|
2022-09-24 00:05:25 -07:00
|
|
|
|
2023-12-15 17:27:33 +00:00
|
|
|
ParseResult parseResult = command.ParseAndApply($"--url \"http://clowd.squirrel.com\"");
|
2022-09-24 00:05:25 -07:00
|
|
|
|
2023-12-15 17:27:33 +00:00
|
|
|
Assert.Empty(parseResult.Errors);
|
|
|
|
|
Assert.Equal("http://clowd.squirrel.com/", command.Url);
|
|
|
|
|
}
|
2022-09-24 00:05:25 -07:00
|
|
|
|
2023-12-15 17:27:33 +00:00
|
|
|
[Fact]
|
|
|
|
|
public void Url_WithNonHttpValue_ShowsError()
|
|
|
|
|
{
|
|
|
|
|
var command = new HttpDownloadCommand();
|
2022-09-24 00:05:25 -07:00
|
|
|
|
2023-12-15 17:27:33 +00:00
|
|
|
ParseResult parseResult = command.ParseAndApply($"--url \"file://clowd.squirrel.com\"");
|
2022-09-24 00:05:25 -07:00
|
|
|
|
2023-12-15 17:27:33 +00:00
|
|
|
Assert.Equal(1, parseResult.Errors.Count);
|
|
|
|
|
//Assert.Equal(command.Url, parseResult.Errors[0].SymbolResult?.Symbol);
|
|
|
|
|
Assert.StartsWith("--url must contain a Uri with one of the following schems: http, https.", parseResult.Errors[0].Message);
|
|
|
|
|
}
|
2022-09-24 00:05:25 -07:00
|
|
|
|
2023-12-15 17:27:33 +00:00
|
|
|
[Fact]
|
|
|
|
|
public void Url_WithRelativeUrl_ShowsError()
|
|
|
|
|
{
|
|
|
|
|
var command = new HttpDownloadCommand();
|
2022-09-24 00:05:25 -07:00
|
|
|
|
2023-12-15 17:27:33 +00:00
|
|
|
ParseResult parseResult = command.ParseAndApply($"--url \"clowd.squirrel.com\"");
|
2022-09-24 00:05:25 -07:00
|
|
|
|
2023-12-15 17:27:33 +00:00
|
|
|
Assert.Equal(1, parseResult.Errors.Count);
|
|
|
|
|
//Assert.Equal(command.Url, parseResult.Errors[0].SymbolResult?.Symbol);
|
|
|
|
|
Assert.StartsWith("--url must contain an absolute Uri.", parseResult.Errors[0].Message);
|
|
|
|
|
}
|
2022-09-24 00:05:25 -07:00
|
|
|
|
2023-12-15 17:27:33 +00:00
|
|
|
protected override string GetRequiredDefaultOptions()
|
|
|
|
|
{
|
|
|
|
|
return $"--url \"https://clowd.squirrel.com\" ";
|
2022-09-24 00:05:25 -07:00
|
|
|
}
|
|
|
|
|
}
|