mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
Rename to Velopack
This commit is contained in:
100
test/Velopack.CommandLine.Tests/Commands/GitHubCommandTests.cs
Normal file
100
test/Velopack.CommandLine.Tests/Commands/GitHubCommandTests.cs
Normal file
@@ -0,0 +1,100 @@
|
||||
using System.CommandLine;
|
||||
using Squirrel.Csq.Commands;
|
||||
|
||||
namespace Squirrel.CommandLine.Tests.Commands;
|
||||
|
||||
public abstract class GitHubCommandTests<T> : BaseCommandTests<T>
|
||||
where T : GitHubBaseCommand, new()
|
||||
{
|
||||
[Fact]
|
||||
public void RepoUrl_WithUrl_ParsesValue()
|
||||
{
|
||||
GitHubBaseCommand command = new T();
|
||||
|
||||
ParseResult parseResult = command.ParseAndApply($"--repoUrl \"http://clowd.squirrel.com\"");
|
||||
|
||||
Assert.Empty(parseResult.Errors);
|
||||
Assert.Equal("http://clowd.squirrel.com/", command.RepoUrl);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RepoUrl_WithNonHttpValue_ShowsError()
|
||||
{
|
||||
GitHubBaseCommand command = new T();
|
||||
|
||||
ParseResult parseResult = command.ParseAndApply($"--repoUrl \"file://clowd.squirrel.com\"");
|
||||
|
||||
Assert.Equal(1, parseResult.Errors.Count);
|
||||
//Assert.Equal(command.RepoUrl, parseResult.Errors[0].SymbolResult?.Symbol);
|
||||
Assert.StartsWith("--repoUrl must contain a Uri with one of the following schems: http, https.", parseResult.Errors[0].Message);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RepoUrl_WithRelativeUrl_ShowsError()
|
||||
{
|
||||
GitHubBaseCommand command = new T();
|
||||
|
||||
ParseResult parseResult = command.ParseAndApply($"--repoUrl \"clowd.squirrel.com\"");
|
||||
|
||||
Assert.Equal(1, parseResult.Errors.Count);
|
||||
//Assert.Equal(command.RepoUrl, parseResult.Errors[0].SymbolResult?.Symbol);
|
||||
Assert.StartsWith("--repoUrl must contain an absolute Uri.", parseResult.Errors[0].Message);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Token_WithValue_ParsesValue()
|
||||
{
|
||||
GitHubBaseCommand command = new T();
|
||||
|
||||
string cli = GetRequiredDefaultOptions() + $"--token \"abc\"";
|
||||
ParseResult parseResult = command.ParseAndApply(cli);
|
||||
|
||||
Assert.Equal("abc", command.Token);
|
||||
}
|
||||
|
||||
protected override string GetRequiredDefaultOptions()
|
||||
{
|
||||
return $"--repoUrl \"https://clowd.squirrel.com\" ";
|
||||
}
|
||||
}
|
||||
|
||||
public class GitHubDownloadCommandTests : GitHubCommandTests<GitHubDownloadCommand>
|
||||
{
|
||||
[Fact]
|
||||
public void Pre_BareOption_SetsFlag()
|
||||
{
|
||||
var command = new GitHubDownloadCommand();
|
||||
|
||||
string cli = GetRequiredDefaultOptions() + "--pre";
|
||||
ParseResult parseResult = command.ParseAndApply(cli);
|
||||
|
||||
Assert.True(command.Pre);
|
||||
}
|
||||
}
|
||||
|
||||
public class GitHubUploadCommandTests : GitHubCommandTests<GitHubUploadCommand>
|
||||
{
|
||||
public override bool ShouldBeNonEmptyReleaseDir => true;
|
||||
|
||||
[Fact]
|
||||
public void Publish_BareOption_SetsFlag()
|
||||
{
|
||||
var command = new GitHubUploadCommand();
|
||||
|
||||
string cli = GetRequiredDefaultOptions() + "--publish";
|
||||
ParseResult parseResult = command.ParseAndApply(cli);
|
||||
|
||||
Assert.True(command.Publish);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReleaseName_WithName_ParsesValue()
|
||||
{
|
||||
var command = new GitHubUploadCommand();
|
||||
|
||||
string cli = GetRequiredDefaultOptions() + $"--releaseName \"my release\"";
|
||||
ParseResult parseResult = command.ParseAndApply(cli);
|
||||
|
||||
Assert.Equal("my release", command.ReleaseName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
|
||||
using System.CommandLine;
|
||||
using Squirrel.Csq.Commands;
|
||||
|
||||
namespace Squirrel.CommandLine.Tests.Commands;
|
||||
|
||||
public class HttpDownloadCommandTests : BaseCommandTests<HttpDownloadCommand>
|
||||
{
|
||||
[Fact]
|
||||
public void Url_WithUrl_ParsesValue()
|
||||
{
|
||||
var command = new HttpDownloadCommand();
|
||||
|
||||
ParseResult parseResult = command.ParseAndApply($"--url \"http://clowd.squirrel.com\"");
|
||||
|
||||
Assert.Empty(parseResult.Errors);
|
||||
Assert.Equal("http://clowd.squirrel.com/", command.Url);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Url_WithNonHttpValue_ShowsError()
|
||||
{
|
||||
var command = new HttpDownloadCommand();
|
||||
|
||||
ParseResult parseResult = command.ParseAndApply($"--url \"file://clowd.squirrel.com\"");
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Url_WithRelativeUrl_ShowsError()
|
||||
{
|
||||
var command = new HttpDownloadCommand();
|
||||
|
||||
ParseResult parseResult = command.ParseAndApply($"--url \"clowd.squirrel.com\"");
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
protected override string GetRequiredDefaultOptions()
|
||||
{
|
||||
return $"--url \"https://clowd.squirrel.com\" ";
|
||||
}
|
||||
}
|
||||
324
test/Velopack.CommandLine.Tests/Commands/OsxCommandTests.cs
Normal file
324
test/Velopack.CommandLine.Tests/Commands/OsxCommandTests.cs
Normal file
@@ -0,0 +1,324 @@
|
||||
//using System.CommandLine;
|
||||
//using System.CommandLine.Parsing;
|
||||
//using Xunit;
|
||||
|
||||
//namespace Squirrel.CommandLine.Tests.Commands
|
||||
//{
|
||||
// public class PackCommandTests : BaseCommandTests<PackOsxCommand>
|
||||
// {
|
||||
// [Fact]
|
||||
// public void Command_WithValidRequiredArguments_Parses()
|
||||
// {
|
||||
// DirectoryInfo packDir = CreateTempDirectory();
|
||||
// CreateTempFile(packDir);
|
||||
// var command = new PackCommand();
|
||||
|
||||
// ParseResult parseResult = command.Parse($"--packId Clowd.Squirrel -v 1.2.3 -p \"{packDir.FullName}\"");
|
||||
|
||||
// Assert.Empty(parseResult.Errors);
|
||||
// Assert.Equal("Clowd.Squirrel", command.PackId);
|
||||
// Assert.Equal("1.2.3", command.PackVersion);
|
||||
// Assert.Equal(packDir.FullName, command.PackDirectory?.FullName);
|
||||
// }
|
||||
|
||||
// [Fact]
|
||||
// public void PackId_WithInvalidNuGetId_ShowsError()
|
||||
// {
|
||||
// DirectoryInfo packDir = CreateTempDirectory();
|
||||
// CreateTempFile(packDir);
|
||||
// var command = new PackCommand();
|
||||
|
||||
// ParseResult parseResult = command.Parse($"--packId $42@ -v 1.0.0 -p \"{packDir.FullName}\"");
|
||||
|
||||
// Assert.Equal(1, parseResult.Errors.Count);
|
||||
// Assert.StartsWith("--packId is an invalid NuGet package id.", parseResult.Errors[0].Message);
|
||||
// Assert.Contains("$42@", parseResult.Errors[0].Message);
|
||||
// }
|
||||
|
||||
// [Fact]
|
||||
// public void PackVersion_WithInvalidVersion_ShowsError()
|
||||
// {
|
||||
// DirectoryInfo packDir = CreateTempDirectory();
|
||||
// CreateTempFile(packDir);
|
||||
// var command = new PackCommand();
|
||||
|
||||
// ParseResult parseResult = command.Parse($"-u Clowd.Squirrel --packVersion 1.a.c -p \"{packDir.FullName}\"");
|
||||
|
||||
// Assert.Equal(1, parseResult.Errors.Count);
|
||||
// Assert.StartsWith("--packVersion contains an invalid package version", parseResult.Errors[0].Message);
|
||||
// Assert.Contains("1.a.c", parseResult.Errors[0].Message);
|
||||
// }
|
||||
|
||||
// [Fact]
|
||||
// public void PackDirectory_WithEmptyFolder_ShowsError()
|
||||
// {
|
||||
// DirectoryInfo packDir = CreateTempDirectory();
|
||||
// var command = new PackCommand();
|
||||
|
||||
// ParseResult parseResult = command.Parse($"-u Clowd.Squirrel -v 1.0.0 --packDir \"{packDir.FullName}\"");
|
||||
|
||||
// Assert.Equal(1, parseResult.Errors.Count);
|
||||
// Assert.StartsWith("--packDir must a non-empty directory", parseResult.Errors[0].Message);
|
||||
// Assert.Contains(packDir.FullName, parseResult.Errors[0].Message);
|
||||
// }
|
||||
|
||||
// [Fact]
|
||||
// public void PackAuthors_WithMultipleAuthors_ParsesValue()
|
||||
// {
|
||||
// var command = new PackCommand();
|
||||
|
||||
// string cli = GetRequiredDefaultOptions() + "--packAuthors Me,mysel,I";
|
||||
// ParseResult parseResult = command.Parse(cli);
|
||||
|
||||
// Assert.Equal("Me,mysel,I", command.PackAuthors);
|
||||
// }
|
||||
|
||||
// [Fact]
|
||||
// public void PackTitle_WithTitle_ParsesValue()
|
||||
// {
|
||||
// var command = new PackCommand();
|
||||
|
||||
// string cli = GetRequiredDefaultOptions() + "--packTitle \"My Awesome Title\"";
|
||||
// ParseResult parseResult = command.Parse(cli);
|
||||
|
||||
// Assert.Equal("My Awesome Title", command.PackTitle);
|
||||
// }
|
||||
|
||||
// [Fact]
|
||||
// public void IncludePdb_BareOption_SetsFlag()
|
||||
// {
|
||||
// var command = new PackCommand();
|
||||
|
||||
// string cli = GetRequiredDefaultOptions() + "--includePdb";
|
||||
// ParseResult parseResult = command.Parse(cli);
|
||||
|
||||
// Assert.True(command.IncludePdb);
|
||||
// }
|
||||
|
||||
// [Fact]
|
||||
// public void ReleaseNotes_WithExistingFile_ParsesValue()
|
||||
// {
|
||||
// FileInfo releaseNotes = CreateTempFile();
|
||||
// var command = new PackCommand();
|
||||
|
||||
// string cli = GetRequiredDefaultOptions() + $"--releaseNotes \"{releaseNotes.FullName}\"";
|
||||
// ParseResult parseResult = command.Parse(cli);
|
||||
|
||||
// Assert.Equal(releaseNotes.FullName, command.ReleaseNotes?.FullName);
|
||||
// }
|
||||
|
||||
// [Fact]
|
||||
// public void ReleaseNotes_WithoutFile_ShowsError()
|
||||
// {
|
||||
// string releaseNotes = Path.GetFullPath(Path.GetRandomFileName());
|
||||
// var command = new PackCommand();
|
||||
|
||||
// string cli = GetRequiredDefaultOptions() + $"--releaseNotes \"{releaseNotes}\"";
|
||||
// ParseResult parseResult = command.Parse(cli);
|
||||
|
||||
// Assert.Equal(1, parseResult.Errors.Count);
|
||||
// Assert.Equal(command.ReleaseNotes, parseResult.Errors[0].SymbolResult?.Symbol.Parents.Single());
|
||||
// Assert.Contains(releaseNotes, parseResult.Errors[0].Message);
|
||||
// }
|
||||
|
||||
// [Fact]
|
||||
// public void SquirrelAwareExecutable_WithFileName_ParsesValue()
|
||||
// {
|
||||
// var command = new PackCommand();
|
||||
|
||||
// string cli = GetRequiredDefaultOptions() + $"--mainExe \"MyApp.exe\"";
|
||||
// ParseResult parseResult = command.Parse(cli);
|
||||
|
||||
// Assert.Equal("MyApp.exe", command.SquirrelAwareExecutable);
|
||||
// }
|
||||
|
||||
// [Fact]
|
||||
// public void Icon_WithValidFile_ParsesValue()
|
||||
// {
|
||||
// FileInfo fileInfo = CreateTempFile(name: Path.ChangeExtension(Path.GetRandomFileName(), ".ico"));
|
||||
// var command = new PackCommand();
|
||||
|
||||
// string cli = GetRequiredDefaultOptions() + $"--icon \"{fileInfo.FullName}\"";
|
||||
// ParseResult parseResult = command.Parse(cli);
|
||||
|
||||
// Assert.Equal(fileInfo.FullName, command.Icon?.FullName);
|
||||
// }
|
||||
|
||||
// [Fact]
|
||||
// public void Icon_WithBadFileExtension_ShowsError()
|
||||
// {
|
||||
// FileInfo fileInfo = CreateTempFile(name: Path.ChangeExtension(Path.GetRandomFileName(), ".wrong"));
|
||||
// var command = new PackCommand();
|
||||
|
||||
// string cli = GetRequiredDefaultOptions() + $"--icon \"{fileInfo.FullName}\"";
|
||||
// ParseResult parseResult = command.Parse(cli);
|
||||
|
||||
// Assert.Equal(1, parseResult.Errors.Count);
|
||||
// Assert.Equal($"--icon does not have an .ico extension", parseResult.Errors[0].Message);
|
||||
// }
|
||||
|
||||
// [Fact]
|
||||
// public void Icon_WithoutFile_ShowsError()
|
||||
// {
|
||||
// string file = Path.GetFullPath(Path.ChangeExtension(Path.GetRandomFileName(), ".ico"));
|
||||
// var command = new PackCommand();
|
||||
|
||||
// string cli = GetRequiredDefaultOptions() + $"--icon \"{file}\"";
|
||||
// ParseResult parseResult = command.Parse(cli);
|
||||
|
||||
// Assert.Equal(1, parseResult.Errors.Count);
|
||||
// Assert.Equal(command.Icon, parseResult.Errors[0].SymbolResult?.Symbol.Parents.Single());
|
||||
// Assert.Contains(file, parseResult.Errors[0].Message);
|
||||
// }
|
||||
|
||||
// [Fact]
|
||||
// public void BundleId_WithValue_ParsesValue()
|
||||
// {
|
||||
// var command = new PackCommand();
|
||||
|
||||
// string cli = GetRequiredDefaultOptions() + $"--bundleId \"some id\"";
|
||||
// ParseResult parseResult = command.Parse(cli);
|
||||
|
||||
// Assert.Equal("some id", command.BundleId);
|
||||
// }
|
||||
|
||||
// [Fact]
|
||||
// public void NoDelta_BareOption_SetsFlag()
|
||||
// {
|
||||
// var command = new PackCommand();
|
||||
|
||||
// string cli = GetRequiredDefaultOptions() + "--noDelta";
|
||||
// ParseResult parseResult = command.Parse(cli);
|
||||
|
||||
// Assert.True(command.NoDelta);
|
||||
// }
|
||||
|
||||
// [Fact]
|
||||
// public void NoPackage_BareOption_SetsFlag()
|
||||
// {
|
||||
// var command = new PackCommand();
|
||||
|
||||
// string cli = GetRequiredDefaultOptions() + "--noPkg";
|
||||
// ParseResult parseResult = command.Parse(cli);
|
||||
|
||||
// Assert.True(command.NoPackage);
|
||||
// }
|
||||
|
||||
// [Fact]
|
||||
// public void PackageContent_CanSpecifyMultipleValues()
|
||||
// {
|
||||
// DirectoryInfo packDir = CreateTempDirectory();
|
||||
// FileInfo testFile1 = CreateTempFile(packDir);
|
||||
// FileInfo testFile2 = CreateTempFile(packDir);
|
||||
// PackCommand command = new PackCommand();
|
||||
// string cli = $"-u clowd.squirrel -v 1.0.0 -p \"{packDir.FullName}\"";
|
||||
// cli += $" --pkgContent welcome={testFile1.FullName}";
|
||||
// cli += $" --pkgContent license={testFile2.FullName}";
|
||||
// ParseResult parseResult = command.Parse(cli);
|
||||
|
||||
// Assert.Empty(parseResult.Errors);
|
||||
// var packageContent = command.PackageContent;
|
||||
// Assert.Equal(2, packageContent?.Length);
|
||||
|
||||
// Assert.Equal("welcome", packageContent![0].Key);
|
||||
// Assert.Equal(testFile1.FullName, packageContent![0].Value.FullName);
|
||||
|
||||
// Assert.Equal("license", packageContent![1].Key);
|
||||
// Assert.Equal(testFile2.FullName, packageContent![1].Value.FullName);
|
||||
// }
|
||||
|
||||
// [Fact]
|
||||
// public void PackageContent_WihtInvalidKey_DisplaysError()
|
||||
// {
|
||||
// DirectoryInfo packDir = CreateTempDirectory();
|
||||
// FileInfo testFile1 = CreateTempFile(packDir);
|
||||
// PackCommand command = new PackCommand();
|
||||
// string cli = $"-u clowd.squirrel -v 1.0.0 -p \"{packDir.FullName}\"";
|
||||
// cli += $" --pkgContent unknown={testFile1.FullName}";
|
||||
// ParseResult parseResult = command.Parse(cli);
|
||||
|
||||
// ParseError error = parseResult.Errors.Single();
|
||||
// Assert.Equal("Invalid pkgContent key: unknown. Must be one of: welcome, readme, license, conclusion", error.Message);
|
||||
// }
|
||||
|
||||
// [Fact]
|
||||
// public void SigningAppIdentity_WithSubject_ParsesValue()
|
||||
// {
|
||||
// var command = new PackCommand();
|
||||
|
||||
// string cli = GetRequiredDefaultOptions() + $"--signAppIdentity \"Mac Developer\"";
|
||||
// ParseResult parseResult = command.Parse(cli);
|
||||
|
||||
// Assert.Equal("Mac Developer", command.SigningAppIdentity);
|
||||
// }
|
||||
|
||||
// [Fact]
|
||||
// public void SigningInstallIdentity_WithSubject_ParsesValue()
|
||||
// {
|
||||
// var command = new PackCommand();
|
||||
|
||||
// string cli = GetRequiredDefaultOptions() + $"--signInstallIdentity \"Mac Developer\"";
|
||||
// ParseResult parseResult = command.Parse(cli);
|
||||
|
||||
// Assert.Equal("Mac Developer", command.SigningInstallIdentity);
|
||||
// }
|
||||
|
||||
// [Fact]
|
||||
// public void SigningEntitlements_WithValidFile_ParsesValue()
|
||||
// {
|
||||
// FileInfo fileInfo = CreateTempFile(name: Path.ChangeExtension(Path.GetRandomFileName(), ".entitlements"));
|
||||
// var command = new PackCommand();
|
||||
|
||||
// string cli = GetRequiredDefaultOptions() + $"--signEntitlements \"{fileInfo.FullName}\"";
|
||||
// ParseResult parseResult = command.Parse(cli);
|
||||
|
||||
// Assert.Equal(fileInfo.FullName, command.SigningEntitlements?.FullName);
|
||||
// }
|
||||
|
||||
// [Fact]
|
||||
// public void SigningEntitlements_WithBadFileExtension_ShowsError()
|
||||
// {
|
||||
// FileInfo fileInfo = CreateTempFile(name: Path.ChangeExtension(Path.GetRandomFileName(), ".wrong"));
|
||||
// var command = new PackCommand();
|
||||
|
||||
// string cli = GetRequiredDefaultOptions() + $"--signEntitlements \"{fileInfo.FullName}\"";
|
||||
// ParseResult parseResult = command.Parse(cli);
|
||||
|
||||
// Assert.Equal(1, parseResult.Errors.Count);
|
||||
// Assert.Equal($"--signEntitlements does not have an .entitlements extension", parseResult.Errors[0].Message);
|
||||
// }
|
||||
|
||||
// [Fact]
|
||||
// public void SigningEntitlements_WithoutFile_ShowsError()
|
||||
// {
|
||||
// string file = Path.GetFullPath(Path.ChangeExtension(Path.GetRandomFileName(), ".entitlements"));
|
||||
// var command = new PackCommand();
|
||||
|
||||
// string cli = GetRequiredDefaultOptions() + $"--signEntitlements \"{file}\"";
|
||||
// ParseResult parseResult = command.Parse(cli);
|
||||
|
||||
// Assert.Equal(1, parseResult.Errors.Count);
|
||||
// Assert.Equal(command.SigningEntitlements, parseResult.Errors[0].SymbolResult?.Symbol.Parents.Single());
|
||||
// Assert.Contains(file, parseResult.Errors[0].Message);
|
||||
// }
|
||||
|
||||
// [Fact]
|
||||
// public void NotaryProfile_WithName_ParsesValue()
|
||||
// {
|
||||
// var command = new PackCommand();
|
||||
|
||||
// string cli = GetRequiredDefaultOptions() + $"--notaryProfile \"profile name\"";
|
||||
// ParseResult parseResult = command.Parse(cli);
|
||||
|
||||
// Assert.Equal("profile name", command.NotaryProfile);
|
||||
// }
|
||||
|
||||
// protected override string GetRequiredDefaultOptions()
|
||||
// {
|
||||
// DirectoryInfo packDir = CreateTempDirectory();
|
||||
// CreateTempFile(packDir);
|
||||
|
||||
// return $"-u Clowd.Squirrel -v 1.0.0 -p \"{packDir.FullName}\" ";
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
121
test/Velopack.CommandLine.Tests/Commands/S3CommandTests.cs
Normal file
121
test/Velopack.CommandLine.Tests/Commands/S3CommandTests.cs
Normal file
@@ -0,0 +1,121 @@
|
||||
using System.CommandLine;
|
||||
using Squirrel.Csq.Commands;
|
||||
|
||||
namespace Squirrel.CommandLine.Tests.Commands;
|
||||
|
||||
public abstract class S3CommandTests<T> : BaseCommandTests<T>
|
||||
where T : S3BaseCommand, new()
|
||||
{
|
||||
[Fact]
|
||||
public void Command_WithRequiredEndpointOptions_ParsesValue()
|
||||
{
|
||||
S3BaseCommand command = new T();
|
||||
|
||||
string cli = $"--keyId \"some key\" --secret \"shhhh\" --endpoint \"http://endpoint\" --bucket \"a-bucket\"";
|
||||
ParseResult parseResult = command.ParseAndApply(cli);
|
||||
|
||||
Assert.Empty(parseResult.Errors);
|
||||
Assert.Equal("some key", command.KeyId);
|
||||
Assert.Equal("shhhh", command.Secret);
|
||||
Assert.Equal("http://endpoint/", command.Endpoint);
|
||||
Assert.Equal("a-bucket", command.Bucket);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Command_WithRequiredRegionOptions_ParsesValue()
|
||||
{
|
||||
S3BaseCommand command = new T();
|
||||
|
||||
string cli = $"--keyId \"some key\" --secret \"shhhh\" --region \"us-west-1\" --bucket \"a-bucket\"";
|
||||
ParseResult parseResult = command.ParseAndApply(cli);
|
||||
|
||||
Assert.Empty(parseResult.Errors);
|
||||
Assert.Equal("some key", command.KeyId);
|
||||
Assert.Equal("shhhh", command.Secret);
|
||||
Assert.Equal("us-west-1", command.Region);
|
||||
Assert.Equal("a-bucket", command.Bucket);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Command_WithoutRegionArgumentValue_ShowsError()
|
||||
{
|
||||
S3BaseCommand command = new T();
|
||||
|
||||
string cli = $"--keyId \"some key\" --secret \"shhhh\" --bucket \"a-bucket\" --region \"\"";
|
||||
ParseResult parseResult = command.ParseAndApply(cli);
|
||||
|
||||
Assert.Equal(1, parseResult.Errors.Count);
|
||||
//Assert.Equal(command.Region, parseResult.Errors[0].SymbolResult?.Symbol);
|
||||
Assert.StartsWith("A region value is required", parseResult.Errors[0].Message);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Command_WithoutRegionAndEndpoint_ShowsError()
|
||||
{
|
||||
S3BaseCommand command = new T();
|
||||
|
||||
string cli = $"--keyId \"some key\" --secret \"shhhh\" --bucket \"a-bucket\"";
|
||||
ParseResult parseResult = command.ParseAndApply(cli);
|
||||
|
||||
Assert.Equal(1, parseResult.Errors.Count);
|
||||
Assert.StartsWith("At least one of the following options are required '--region' and '--endpoint'", parseResult.Errors[0].Message);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Command_WithBothRegionAndEndpoint_ShowsError()
|
||||
{
|
||||
S3BaseCommand command = new T();
|
||||
|
||||
string cli = $"--keyId \"some key\" --secret \"shhhh\" --region \"us-west-1\" --endpoint \"http://endpoint\" --bucket \"a-bucket\"";
|
||||
ParseResult parseResult = command.ParseAndApply(cli);
|
||||
|
||||
Assert.Equal(1, parseResult.Errors.Count);
|
||||
Assert.StartsWith("Cannot use '--region' and '--endpoint' options together", parseResult.Errors[0].Message);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PathPrefix_WithPath_ParsesValue()
|
||||
{
|
||||
S3BaseCommand command = new T();
|
||||
|
||||
string cli = GetRequiredDefaultOptions() + $"--pathPrefix \"sub-folder\"";
|
||||
ParseResult parseResult = command.ParseAndApply(cli);
|
||||
|
||||
Assert.Equal("sub-folder", command.PathPrefix);
|
||||
}
|
||||
|
||||
protected override string GetRequiredDefaultOptions()
|
||||
{
|
||||
return $"--keyId \"some key\" --secret \"shhhh\" --endpoint \"http://endpoint\" --bucket \"a-bucket\" ";
|
||||
}
|
||||
}
|
||||
|
||||
public class S3DownloadCommandTests : S3CommandTests<S3DownloadCommand>
|
||||
{ }
|
||||
|
||||
public class S3UploadCommandTests : S3CommandTests<S3UploadCommand>
|
||||
{
|
||||
public override bool ShouldBeNonEmptyReleaseDir => true;
|
||||
|
||||
[Fact]
|
||||
public void Overwrite_BareOption_SetsFlag()
|
||||
{
|
||||
var command = new S3UploadCommand();
|
||||
|
||||
string cli = GetRequiredDefaultOptions() + "--overwrite";
|
||||
ParseResult parseResult = command.ParseAndApply(cli);
|
||||
|
||||
Assert.True(command.Overwrite);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void KeepMaxReleases_WithNumber_ParsesValue()
|
||||
{
|
||||
var command = new S3UploadCommand();
|
||||
|
||||
string cli = GetRequiredDefaultOptions() + "--keepMaxReleases 42";
|
||||
ParseResult parseResult = command.ParseAndApply(cli);
|
||||
|
||||
Assert.Equal(42, command.KeepMaxReleases);
|
||||
}
|
||||
}
|
||||
507
test/Velopack.CommandLine.Tests/Commands/WindowsCommandTests.cs
Normal file
507
test/Velopack.CommandLine.Tests/Commands/WindowsCommandTests.cs
Normal file
@@ -0,0 +1,507 @@
|
||||
|
||||
using System.CommandLine;
|
||||
using Squirrel.Csq.Commands;
|
||||
|
||||
namespace Squirrel.CommandLine.Tests.Commands;
|
||||
|
||||
public abstract class ReleaseCommandTests<T> : BaseCommandTests<T>
|
||||
where T : WindowsReleasifyCommand, new()
|
||||
{
|
||||
//[Fact]
|
||||
//public void BaseUrl_WithNonHttpValue_ShowsError()
|
||||
//{
|
||||
// var command = new T();
|
||||
|
||||
// string cli = GetRequiredDefaultOptions() + $"--baseUrl \"file://clowd.squirrel.com\"";
|
||||
// ParseResult parseResult = command.ParseAndApply(cli);
|
||||
|
||||
// Assert.Equal(1, parseResult.Errors.Count);
|
||||
// //Assert.Equal(command.BaseUrl, parseResult.Errors[0].SymbolResult?.Symbol);
|
||||
// Assert.StartsWith("--baseUrl must contain a Uri with one of the following schems: http, https.", parseResult.Errors[0].Message);
|
||||
//}
|
||||
|
||||
//[Fact]
|
||||
//public void BaseUrl_WithRelativeUrl_ShowsError()
|
||||
//{
|
||||
// var command = new T();
|
||||
// string cli = GetRequiredDefaultOptions() + $"--baseUrl \"clowd.squirrel.com\"";
|
||||
// ParseResult parseResult = command.ParseAndApply(cli);
|
||||
|
||||
// Assert.Equal(1, parseResult.Errors.Count);
|
||||
// //Assert.Equal(command.BaseUrl, parseResult.Errors[0].SymbolResult?.Symbol);
|
||||
// Assert.StartsWith("--baseUrl must contain an absolute Uri.", parseResult.Errors[0].Message);
|
||||
//}
|
||||
|
||||
[Fact]
|
||||
public void NoDelta_BareOption_SetsFlag()
|
||||
{
|
||||
var command = new T();
|
||||
|
||||
string cli = GetRequiredDefaultOptions() + "--delta none";
|
||||
ParseResult parseResult = command.ParseAndApply(cli);
|
||||
|
||||
Assert.True(command.Delta == Packaging.DeltaMode.None);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Runtime_WithValue_ParsesValue()
|
||||
{
|
||||
var command = new T();
|
||||
string cli = GetRequiredDefaultOptions() + $"--framework \"net6,vcredist143\"";
|
||||
ParseResult parseResult = command.ParseAndApply(cli);
|
||||
|
||||
Assert.Equal("net6,vcredist143", command.Runtimes);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SplashImage_WithValidFile_ParsesValue()
|
||||
{
|
||||
FileInfo fileInfo = CreateTempFile(name: Path.ChangeExtension(Path.GetRandomFileName(), ".ico"));
|
||||
var command = new T();
|
||||
|
||||
string cli = GetRequiredDefaultOptions() + $"--splashImage \"{fileInfo.FullName}\"";
|
||||
ParseResult parseResult = command.ParseAndApply(cli);
|
||||
|
||||
Assert.Equal(fileInfo.FullName, command.SplashImage);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SplashImage_WithoutFile_ShowsError()
|
||||
{
|
||||
string file = Path.GetFullPath(Path.ChangeExtension(Path.GetRandomFileName(), ".ico"));
|
||||
var command = new T();
|
||||
|
||||
string cli = GetRequiredDefaultOptions() + $"--splashImage \"{file}\"";
|
||||
ParseResult parseResult = command.ParseAndApply(cli);
|
||||
|
||||
//Assert.Equal(1, parseResult.Errors.Count);
|
||||
Assert.Contains("file is not found", parseResult.Errors[0].Message);
|
||||
//Assert.Equal(command.SplashImage, parseResult.Errors[0].SymbolResult?.Symbol.Parents.Single());
|
||||
//Assert.Contains(file, parseResult.Errors[0].Message);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Icon_WithValidFile_ParsesValue()
|
||||
{
|
||||
FileInfo fileInfo = CreateTempFile(name: Path.ChangeExtension(Path.GetRandomFileName(), ".ico"));
|
||||
var command = new T();
|
||||
|
||||
string cli = GetRequiredDefaultOptions() + $"--icon \"{fileInfo.FullName}\"";
|
||||
ParseResult parseResult = command.ParseAndApply(cli);
|
||||
|
||||
Assert.Equal(fileInfo.FullName, command.Icon);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Icon_WithBadFileExtension_ShowsError()
|
||||
{
|
||||
FileInfo fileInfo = CreateTempFile(name: Path.ChangeExtension(Path.GetRandomFileName(), ".wrong"));
|
||||
var command = new T();
|
||||
|
||||
string cli = GetRequiredDefaultOptions() + $"--icon \"{fileInfo.FullName}\"";
|
||||
ParseResult parseResult = command.ParseAndApply(cli);
|
||||
|
||||
//Assert.Equal(1, parseResult.Errors.Count);
|
||||
Assert.Contains(parseResult.Errors, e => e.Message.Equals($"--icon does not have an .ico extension"));
|
||||
//Assert.Equal($"--icon does not have an .ico extension", parseResult.Errors[0].Message);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Icon_WithoutFile_ShowsError()
|
||||
{
|
||||
string file = Path.GetFullPath(Path.ChangeExtension(Path.GetRandomFileName(), ".ico"));
|
||||
var command = new T();
|
||||
|
||||
string cli = GetRequiredDefaultOptions() + $"--icon \"{file}\"";
|
||||
ParseResult parseResult = command.ParseAndApply(cli);
|
||||
|
||||
//Assert.Equal(1, parseResult.Errors.Count);
|
||||
//Assert.Equal(command.Icon, parseResult.Errors[0].SymbolResult?.Symbol.Parents.Single());
|
||||
Assert.Contains("file is not found", parseResult.Errors[0].Message);
|
||||
}
|
||||
|
||||
//[Fact]
|
||||
//public void SquirrelAwareExecutable_WithMultipleValues_ParsesValue()
|
||||
//{
|
||||
// var command = new T();
|
||||
|
||||
// string cli = GetRequiredDefaultOptions() + $"--mainExe \"MyApp1.exe\"";
|
||||
// ParseResult parseResult = command.ParseAndApply(cli);
|
||||
|
||||
// string searchPaths = command.EntryExecutableName;
|
||||
// Assert.Equal("MyApp1.exe", searchPaths);
|
||||
//}
|
||||
}
|
||||
|
||||
public class ReleasifyWindowsCommandTests : ReleaseCommandTests<WindowsReleasifyCommand>
|
||||
{
|
||||
[Fact]
|
||||
public void Command_WithValidRequiredArguments_Parses()
|
||||
{
|
||||
FileInfo package = CreateTempFile(name: Path.ChangeExtension(Path.GetRandomFileName(), ".nupkg"));
|
||||
var command = new WindowsReleasifyCommand();
|
||||
|
||||
ParseResult parseResult = command.ParseAndApply($"--package \"{package.FullName}\" -e main.exe");
|
||||
|
||||
Assert.Empty(parseResult.Errors);
|
||||
Assert.Equal(package.FullName, command.Package);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Package_WithoutNupkgExtension_ShowsError()
|
||||
{
|
||||
FileInfo package = CreateTempFile(name: Path.ChangeExtension(Path.GetRandomFileName(), ".notpkg"));
|
||||
var command = new WindowsReleasifyCommand();
|
||||
|
||||
ParseResult parseResult = command.ParseAndApply($"--package \"{package.FullName}\" -e main.exe");
|
||||
|
||||
//Assert.Equal(1, parseResult.Errors.Count);
|
||||
//Assert.Equal(command.Package, parseResult.Errors[0].SymbolResult?.Symbol);
|
||||
Assert.StartsWith("--package does not have an .nupkg extension", parseResult.Errors[0].Message);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Package_WithoutExistingFile_ShowsError()
|
||||
{
|
||||
string package = Path.ChangeExtension(Path.GetRandomFileName(), ".nupkg");
|
||||
var command = new WindowsReleasifyCommand();
|
||||
|
||||
ParseResult parseResult = command.ParseAndApply($"--package \"{package}\" -e main.exe");
|
||||
|
||||
//Assert.Equal(1, parseResult.Errors.Count);
|
||||
//Assert.Equal(command.Package, parseResult.Errors[0].SymbolResult?.Symbol.Parents.Single());
|
||||
Assert.Contains("file is not found", parseResult.Errors[0].Message);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SignTemplate_WithTemplate_ParsesValue()
|
||||
{
|
||||
var command = new WindowsReleasifyCommand();
|
||||
|
||||
string cli = GetRequiredDefaultOptions() + "--signTemplate \"signtool {{file}}\"";
|
||||
ParseResult parseResult = command.ParseAndApply(cli);
|
||||
|
||||
Assert.Equal("signtool {{file}}", command.SignTemplate);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SignTemplate_WithoutFileParameter_ShowsError()
|
||||
{
|
||||
var command = new WindowsReleasifyCommand();
|
||||
|
||||
string cli = GetRequiredDefaultOptions() + "--signTemplate \"signtool file\"";
|
||||
ParseResult parseResult = command.ParseAndApply(cli);
|
||||
|
||||
//Assert.Equal(1, parseResult.Errors.Count);
|
||||
//Assert.Equal(command.SignTemplate, parseResult.Errors[0].SymbolResult?.Symbol);
|
||||
Assert.StartsWith("--signTemplate must contain '{{file}}'", parseResult.Errors[0].Message);
|
||||
}
|
||||
|
||||
[WindowsOnlyFact]
|
||||
public void SignParameters_WithParameters_ParsesValue()
|
||||
{
|
||||
var command = new WindowsReleasifyCommand();
|
||||
|
||||
string cli = GetRequiredDefaultOptions() + "--signParams \"param1 param2\"";
|
||||
ParseResult parseResult = command.ParseAndApply(cli);
|
||||
|
||||
Assert.Equal("param1 param2", command.SignParameters);
|
||||
}
|
||||
|
||||
[WindowsOnlyFact]
|
||||
public void SignParameters_WithSignTemplate_ShowsError()
|
||||
{
|
||||
var command = new WindowsReleasifyCommand();
|
||||
|
||||
string cli = GetRequiredDefaultOptions() + "--signTemplate \"signtool {{file}}\" --signParams \"param1 param2\"";
|
||||
ParseResult parseResult = command.ParseAndApply(cli);
|
||||
|
||||
Assert.Equal(1, parseResult.Errors.Count);
|
||||
Assert.Contains("Cannot use", parseResult.Errors[0].Message);
|
||||
Assert.Contains("options together", parseResult.Errors[0].Message);
|
||||
}
|
||||
|
||||
[WindowsOnlyFact]
|
||||
public void SignSkipDll_BareOption_SetsFlag()
|
||||
{
|
||||
var command = new WindowsReleasifyCommand();
|
||||
|
||||
string cli = GetRequiredDefaultOptions() + "--signSkipDll";
|
||||
ParseResult parseResult = command.ParseAndApply(cli);
|
||||
|
||||
Assert.True(command.SignSkipDll);
|
||||
}
|
||||
|
||||
[WindowsOnlyFact]
|
||||
public void SignParallel_WithValue_SetsFlag()
|
||||
{
|
||||
var command = new WindowsReleasifyCommand();
|
||||
|
||||
string cli = GetRequiredDefaultOptions() + "--signParallel 42";
|
||||
ParseResult parseResult = command.ParseAndApply(cli);
|
||||
|
||||
Assert.Equal(42, command.SignParallel);
|
||||
}
|
||||
|
||||
//[WindowsOnlyTheory]
|
||||
//[InlineData(-1)]
|
||||
//[InlineData(0)]
|
||||
//[InlineData(1001)]
|
||||
//public void SignParallel_WithBadNumericValue_ShowsError(int value)
|
||||
//{
|
||||
// var command = new WindowsReleasifyCommand();
|
||||
|
||||
// string cli = GetRequiredDefaultOptions() + $"--signParallel {value}";
|
||||
// ParseResult parseResult = command.ParseAndApply(cli);
|
||||
|
||||
// Assert.Equal(1, parseResult.Errors.Count);
|
||||
// //Assert.Equal(command.SignParallel, parseResult.Errors[0].SymbolResult?.Symbol);
|
||||
// Assert.Equal($"The value for --signParallel must be greater than 1 and less than 1000", parseResult.Errors[0].Message);
|
||||
//}
|
||||
|
||||
//[WindowsOnlyFact]
|
||||
//public void SignParallel_WithNonNumericValue_ShowsError()
|
||||
//{
|
||||
// var command = new WindowsReleasifyCommand();
|
||||
|
||||
// string cli = GetRequiredDefaultOptions() + $"--signParallel abc";
|
||||
// ParseResult parseResult = command.ParseAndApply(cli);
|
||||
|
||||
// Assert.Equal(1, parseResult.Errors.Count);
|
||||
// //Assert.Equal(command.SignParallel, parseResult.Errors[0].SymbolResult?.Symbol);
|
||||
// Assert.Equal($"abc is not a valid integer for --signParallel", parseResult.Errors[0].Message);
|
||||
//}
|
||||
|
||||
protected override string GetRequiredDefaultOptions()
|
||||
{
|
||||
FileInfo package = CreateTempFile(name: Path.ChangeExtension(Path.GetRandomFileName(), ".nupkg"));
|
||||
|
||||
return $"-p \"{package.FullName}\" -e main.exe ";
|
||||
}
|
||||
}
|
||||
|
||||
public class PackWindowsCommandTests : ReleaseCommandTests<WindowsPackCommand>
|
||||
{
|
||||
[Fact]
|
||||
public void Command_WithValidRequiredArguments_Parses()
|
||||
{
|
||||
DirectoryInfo packDir = CreateTempDirectory();
|
||||
CreateTempFile(packDir);
|
||||
var command = new WindowsPackCommand();
|
||||
|
||||
ParseResult parseResult = command.ParseAndApply($"-u Clowd.Squirrel -v 1.2.3 -p \"{packDir.FullName}\" -e main.exe");
|
||||
|
||||
Assert.Empty(parseResult.Errors);
|
||||
Assert.Equal("Clowd.Squirrel", command.PackId);
|
||||
Assert.Equal("1.2.3", command.PackVersion);
|
||||
Assert.Equal(packDir.FullName, command.PackDirectory);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PackId_WithInvalidNuGetId_ShowsError()
|
||||
{
|
||||
DirectoryInfo packDir = CreateTempDirectory();
|
||||
CreateTempFile(packDir);
|
||||
var command = new WindowsPackCommand();
|
||||
|
||||
ParseResult parseResult = command.ParseAndApply($"--packId $42@ -v 1.0.0 -p \"{packDir.FullName}\" -e main.exe");
|
||||
|
||||
Assert.Equal(1, parseResult.Errors.Count);
|
||||
Assert.StartsWith("--packId is an invalid NuGet package id.", parseResult.Errors[0].Message);
|
||||
Assert.Contains("$42@", parseResult.Errors[0].Message);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PackName_WithValue_ParsesValue()
|
||||
{
|
||||
DirectoryInfo packDir = CreateTempDirectory();
|
||||
CreateTempFile(packDir);
|
||||
var command = new WindowsPackCommand();
|
||||
|
||||
ParseResult parseResult = command.ParseAndApply($"-u Clowd.Squirrel --packTitle Clowd.Squirrel -v 1.0.0 -p \"{packDir.FullName}\" -e main.exe");
|
||||
|
||||
Assert.Equal("Clowd.Squirrel", command.PackTitle);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PackVersion_WithInvalidVersion_ShowsError()
|
||||
{
|
||||
DirectoryInfo packDir = CreateTempDirectory();
|
||||
CreateTempFile(packDir);
|
||||
var command = new WindowsPackCommand();
|
||||
|
||||
ParseResult parseResult = command.ParseAndApply($"-u Clowd.Squirrel --packVersion 1.a.c -p \"{packDir.FullName}\" -e main.exe");
|
||||
|
||||
Assert.Equal(1, parseResult.Errors.Count);
|
||||
Assert.StartsWith("--packVersion contains an invalid package version", parseResult.Errors[0].Message);
|
||||
Assert.Contains("1.a.c", parseResult.Errors[0].Message);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PackTitle_WithTitle_ParsesValue()
|
||||
{
|
||||
var command = new WindowsPackCommand();
|
||||
|
||||
string cli = GetRequiredDefaultOptions() + "--packTitle \"My Awesome Title\"";
|
||||
ParseResult parseResult = command.ParseAndApply(cli);
|
||||
|
||||
Assert.Equal("My Awesome Title", command.PackTitle);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PackAuthors_WithMultipleAuthors_ParsesValue()
|
||||
{
|
||||
var command = new WindowsPackCommand();
|
||||
|
||||
string cli = GetRequiredDefaultOptions() + "--packAuthors Me,mysel,I";
|
||||
ParseResult parseResult = command.ParseAndApply(cli);
|
||||
|
||||
Assert.Equal("Me,mysel,I", command.PackAuthors);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IncludePdb_BareOption_SetsFlag()
|
||||
{
|
||||
var command = new WindowsPackCommand();
|
||||
|
||||
string cli = GetRequiredDefaultOptions() + "--includePdb";
|
||||
ParseResult parseResult = command.ParseAndApply(cli);
|
||||
|
||||
Assert.True(command.IncludePdb);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReleaseNotes_WithExistingFile_ParsesValue()
|
||||
{
|
||||
FileInfo releaseNotes = CreateTempFile();
|
||||
var command = new WindowsPackCommand();
|
||||
|
||||
string cli = GetRequiredDefaultOptions() + $"--releaseNotes \"{releaseNotes.FullName}\"";
|
||||
ParseResult parseResult = command.ParseAndApply(cli);
|
||||
|
||||
Assert.Equal(releaseNotes.FullName, command.ReleaseNotes);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReleaseNotes_WithoutFile_ShowsError()
|
||||
{
|
||||
string releaseNotes = Path.GetFullPath(Path.GetRandomFileName());
|
||||
var command = new WindowsPackCommand();
|
||||
|
||||
string cli = GetRequiredDefaultOptions() + $"--releaseNotes \"{releaseNotes}\"";
|
||||
ParseResult parseResult = command.ParseAndApply(cli);
|
||||
|
||||
Assert.Equal(1, parseResult.Errors.Count);
|
||||
Assert.Contains("file is not found", parseResult.Errors[0].Message);
|
||||
//Assert.Equal(command.ReleaseNotes, parseResult.Errors[0].SymbolResult?.Symbol.Parents.Single());
|
||||
//Assert.Contains(releaseNotes, parseResult.Errors[0].Message);
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void SignTemplate_WithTemplate_ParsesValue()
|
||||
{
|
||||
var command = new WindowsPackCommand();
|
||||
|
||||
string cli = GetRequiredDefaultOptions() + "--signTemplate \"signtool {{file}}\"";
|
||||
ParseResult parseResult = command.ParseAndApply(cli);
|
||||
|
||||
Assert.Equal("signtool {{file}}", command.SignTemplate);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SignTemplate_WithoutFileParameter_ShowsError()
|
||||
{
|
||||
var command = new WindowsPackCommand();
|
||||
|
||||
string cli = GetRequiredDefaultOptions() + "--signTemplate \"signtool file\"";
|
||||
ParseResult parseResult = command.ParseAndApply(cli);
|
||||
|
||||
Assert.Equal(1, parseResult.Errors.Count);
|
||||
//Assert.Equal(command.SignTemplate, parseResult.Errors[0].SymbolResult?.Symbol);
|
||||
Assert.StartsWith("--signTemplate must contain '{{file}}'", parseResult.Errors[0].Message);
|
||||
}
|
||||
|
||||
[WindowsOnlyFact]
|
||||
public void SignParameters_WithParameters_ParsesValue()
|
||||
{
|
||||
var command = new WindowsPackCommand();
|
||||
|
||||
string cli = GetRequiredDefaultOptions() + "--signParams \"param1 param2\"";
|
||||
ParseResult parseResult = command.ParseAndApply(cli);
|
||||
|
||||
Assert.Equal("param1 param2", command.SignParameters);
|
||||
}
|
||||
|
||||
[WindowsOnlyFact]
|
||||
public void SignParameters_WithSignTemplate_ShowsError()
|
||||
{
|
||||
var command = new WindowsPackCommand();
|
||||
|
||||
string cli = GetRequiredDefaultOptions() + "--signTemplate \"signtool {{file}}\" --signParams \"param1 param2\"";
|
||||
ParseResult parseResult = command.ParseAndApply(cli);
|
||||
|
||||
Assert.Equal(1, parseResult.Errors.Count);
|
||||
Assert.Contains("Cannot use", parseResult.Errors[0].Message);
|
||||
Assert.Contains("options together", parseResult.Errors[0].Message);
|
||||
}
|
||||
|
||||
[WindowsOnlyFact]
|
||||
public void SignSkipDll_BareOption_SetsFlag()
|
||||
{
|
||||
var command = new WindowsPackCommand();
|
||||
|
||||
string cli = GetRequiredDefaultOptions() + "--signSkipDll";
|
||||
ParseResult parseResult = command.ParseAndApply(cli);
|
||||
|
||||
Assert.True(command.SignSkipDll);
|
||||
}
|
||||
|
||||
[WindowsOnlyFact]
|
||||
public void SignParallel_WithValue_SetsFlag()
|
||||
{
|
||||
var command = new WindowsPackCommand();
|
||||
|
||||
string cli = GetRequiredDefaultOptions() + "--signParallel 42";
|
||||
ParseResult parseResult = command.ParseAndApply(cli);
|
||||
|
||||
Assert.Equal(42, command.SignParallel);
|
||||
}
|
||||
|
||||
[WindowsOnlyTheory]
|
||||
[InlineData(-1)]
|
||||
[InlineData(0)]
|
||||
[InlineData(1001)]
|
||||
public void SignParallel_WithBadNumericValue_ShowsError(int value)
|
||||
{
|
||||
var command = new WindowsPackCommand();
|
||||
|
||||
string cli = GetRequiredDefaultOptions() + $"--signParallel {value}";
|
||||
ParseResult parseResult = command.ParseAndApply(cli);
|
||||
|
||||
Assert.Equal(1, parseResult.Errors.Count);
|
||||
//Assert.Equal(command.SignParallel, parseResult.Errors[0].SymbolResult?.Symbol);
|
||||
Assert.Equal($"The value for --signParallel must be greater than 1 and less than 1000", parseResult.Errors[0].Message);
|
||||
}
|
||||
|
||||
//[WindowsOnlyFact]
|
||||
//public void SignParallel_WithNonNumericValue_ShowsError()
|
||||
//{
|
||||
// var command = new WindowsPackCommand();
|
||||
|
||||
// string cli = GetRequiredDefaultOptions() + $"--signParallel abc";
|
||||
// ParseResult parseResult = command.ParseAndApply(cli);
|
||||
|
||||
// Assert.Equal(1, parseResult.Errors.Count);
|
||||
// //Assert.Equal(command.SignParallel, parseResult.Errors[0].SymbolResult?.Symbol);
|
||||
// Assert.Equal($"abc is not a valid integer for --signParallel", parseResult.Errors[0].Message);
|
||||
//}
|
||||
|
||||
protected override string GetRequiredDefaultOptions()
|
||||
{
|
||||
DirectoryInfo packDir = CreateTempDirectory();
|
||||
CreateTempFile(packDir);
|
||||
|
||||
return $"-u Clowd.Squirrel -v 1.0.0 -p \"{packDir.FullName}\" -e main.exe ";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user