mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
Add a method to create fake squirrel-aware app packages at will
This commit is contained in:
@@ -8,6 +8,7 @@ using Ionic.Zip;
|
|||||||
using Squirrel;
|
using Squirrel;
|
||||||
using Splat;
|
using Splat;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
namespace Squirrel.Tests.TestHelpers
|
namespace Squirrel.Tests.TestHelpers
|
||||||
{
|
{
|
||||||
@@ -69,6 +70,48 @@ namespace Squirrel.Tests.TestHelpers
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string CreateFakeInstalledApp(string version, string outputDir, string nuspecFile = null)
|
||||||
|
{
|
||||||
|
var targetDir = default(string);
|
||||||
|
|
||||||
|
var nuget = IntegrationTestHelper.GetPath("..", ".nuget", "nuget.exe");
|
||||||
|
nuspecFile = nuspecFile ?? "SquirrelInstalledApp.nuspec";
|
||||||
|
|
||||||
|
using (var clearTemp = Utility.WithTempDirectory(out targetDir)) {
|
||||||
|
var nuspec = File.ReadAllText(IntegrationTestHelper.GetPath("fixtures", nuspecFile), Encoding.UTF8);
|
||||||
|
File.WriteAllText(Path.Combine(targetDir, nuspecFile), nuspec.Replace("0.1.0", version), Encoding.UTF8);
|
||||||
|
|
||||||
|
File.Copy(
|
||||||
|
IntegrationTestHelper.GetPath("fixtures", "SquirrelAwareApp.exe"),
|
||||||
|
Path.Combine(targetDir, "SquirrelAwareApp.exe"));
|
||||||
|
File.Copy(
|
||||||
|
IntegrationTestHelper.GetPath("fixtures", "NotSquirrelAwareApp.exe"),
|
||||||
|
Path.Combine(targetDir, "NotSquirrelAwareApp.exe"));
|
||||||
|
|
||||||
|
var psi = new ProcessStartInfo(nuget, "pack " + Path.Combine(targetDir, nuspecFile)) {
|
||||||
|
RedirectStandardError = true,
|
||||||
|
RedirectStandardOutput = true,
|
||||||
|
UseShellExecute = false,
|
||||||
|
CreateNoWindow = true,
|
||||||
|
WorkingDirectory = targetDir,
|
||||||
|
WindowStyle = ProcessWindowStyle.Hidden,
|
||||||
|
};
|
||||||
|
|
||||||
|
var pi = Process.Start(psi);
|
||||||
|
pi.WaitForExit();
|
||||||
|
var output = pi.StandardOutput.ReadToEnd();
|
||||||
|
var err = pi.StandardError.ReadToEnd();
|
||||||
|
Console.WriteLine(output); Console.WriteLine(err);
|
||||||
|
|
||||||
|
var di = new DirectoryInfo(targetDir);
|
||||||
|
var pkg = di.EnumerateFiles("*.nupkg").First();
|
||||||
|
|
||||||
|
var targetPkgFile = Path.Combine(outputDir, pkg.Name);
|
||||||
|
File.Copy(pkg.FullName, targetPkgFile);
|
||||||
|
return targetPkgFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static IDisposable WithFakeInstallDirectory(out string path)
|
public static IDisposable WithFakeInstallDirectory(out string path)
|
||||||
{
|
{
|
||||||
return WithFakeInstallDirectory("SampleUpdatingApp.1.1.0.0.nupkg", out path);
|
return WithFakeInstallDirectory("SampleUpdatingApp.1.1.0.0.nupkg", out path);
|
||||||
|
|||||||
@@ -52,6 +52,16 @@ namespace Squirrel.Tests.Core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void CreateFakePackageSmokeTest()
|
||||||
|
{
|
||||||
|
string path;
|
||||||
|
using (Utility.WithTempDirectory(out path)) {
|
||||||
|
var output = IntegrationTestHelper.CreateFakeInstalledApp("0.3.0", path);
|
||||||
|
Assert.True(File.Exists(output));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void CreateSampleDirectory(string directory)
|
static void CreateSampleDirectory(string directory)
|
||||||
{
|
{
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|||||||
14
test/fixtures/SquirrelInstalledApp.nuspec
vendored
Normal file
14
test/fixtures/SquirrelInstalledApp.nuspec
vendored
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||||
|
<metadata>
|
||||||
|
<id>SquirrelInstalledApp</id>
|
||||||
|
<version>0.1.0</version>
|
||||||
|
<authors>paul</authors>
|
||||||
|
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||||
|
<description>My package description.</description>
|
||||||
|
</metadata>
|
||||||
|
<files>
|
||||||
|
<file src="NotSquirrelAwareApp.exe" target="lib\net45\NotSquirrelAwareApp.exe" />
|
||||||
|
<file src="SquirrelAwareApp.exe" target="lib\net45\SquirrelAwareApp.exe" />
|
||||||
|
</files>
|
||||||
|
</package>
|
||||||
Reference in New Issue
Block a user