2024-02-03 22:17:31 -05:00
|
|
|
using System.CommandLine;
|
2024-09-21 12:48:05 -06:00
|
|
|
using Velopack.Util;
|
2024-03-27 20:50:53 +00:00
|
|
|
using Velopack.Vpk.Commands.Deployment;
|
2024-02-03 22:17:31 -05:00
|
|
|
|
|
|
|
|
namespace Velopack.CommandLine.Tests.Commands;
|
2024-02-04 07:53:10 -05:00
|
|
|
public class LocalDownloadCommandTests : BaseCommandTests<LocalDownloadCommand>
|
2024-02-03 22:17:31 -05:00
|
|
|
{
|
|
|
|
|
[Fact]
|
|
|
|
|
public void Path_WithPath_ParsesValue()
|
|
|
|
|
{
|
2024-02-04 07:53:10 -05:00
|
|
|
var command = new LocalDownloadCommand();
|
2024-02-03 22:17:31 -05:00
|
|
|
|
2024-09-21 12:48:05 -06:00
|
|
|
using var _1 = TempUtil.GetTempDirectory(out var releaseDir);
|
2024-03-28 11:11:23 +00:00
|
|
|
File.Create(Path.Combine(releaseDir, "test.txt")).Close();
|
|
|
|
|
|
|
|
|
|
ParseResult parseResult = command.ParseAndApply($"--path {releaseDir}");
|
2024-02-03 22:17:31 -05:00
|
|
|
|
|
|
|
|
Assert.Empty(parseResult.Errors);
|
2024-03-28 11:11:23 +00:00
|
|
|
Assert.Equal(releaseDir, command.TargetPath.FullName);
|
|
|
|
|
}
|
2024-02-03 22:17:31 -05:00
|
|
|
|
2024-03-28 11:11:23 +00:00
|
|
|
[Fact]
|
|
|
|
|
public void Path_WithEmptyPath_ParsesValue()
|
|
|
|
|
{
|
|
|
|
|
var command = new LocalDownloadCommand();
|
2024-09-21 12:48:05 -06:00
|
|
|
using var _1 = TempUtil.GetTempDirectory(out var releaseDir);
|
2024-03-28 11:11:23 +00:00
|
|
|
|
|
|
|
|
ParseResult parseResult = command.ParseAndApply($"--path {releaseDir}");
|
|
|
|
|
|
|
|
|
|
Assert.True(parseResult.Errors.Count > 0);
|
|
|
|
|
Assert.Contains("must be a non-empty directory", parseResult.Errors[0].Message);
|
2024-02-03 22:17:31 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void Path_WithNonExistingDirectory_ShowsError()
|
|
|
|
|
{
|
2024-02-04 07:53:10 -05:00
|
|
|
var command = new LocalDownloadCommand();
|
2024-02-03 22:17:31 -05:00
|
|
|
|
|
|
|
|
// Parse with a fake path
|
2024-02-04 18:56:45 +00:00
|
|
|
ParseResult parseResult = command.ParseAndApply($"--path \"E:\\releases\"");
|
2024-02-03 22:17:31 -05:00
|
|
|
|
2024-03-28 11:11:23 +00:00
|
|
|
Assert.True(parseResult.Errors.Count > 0);
|
|
|
|
|
Assert.Contains("must be a non-empty directory", parseResult.Errors[0].Message);
|
2024-02-03 22:17:31 -05:00
|
|
|
}
|
|
|
|
|
}
|