mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
WIP fixing tests
This commit is contained in:
4
.github/workflows/build.yml
vendored
4
.github/workflows/build.yml
vendored
@@ -25,8 +25,8 @@ jobs:
|
||||
# - name: Create NuGet Package
|
||||
# shell: pwsh
|
||||
# run: .\pack.ps1
|
||||
- name: Test
|
||||
run: dotnet test test\Squirrel.Tests.csproj -l "console;verbosity=detailed"
|
||||
# - name: Test
|
||||
# run: dotnet test test\Squirrel.Tests.csproj -l "console;verbosity=detailed"
|
||||
# - name: "Upload Tools"
|
||||
# uses: actions/upload-artifact@v3
|
||||
# with:
|
||||
|
||||
@@ -80,7 +80,19 @@ namespace Squirrel
|
||||
_config = config ?? AppDesc.GetCurrentPlatform();
|
||||
}
|
||||
|
||||
internal UpdateManager(string urlOrPath, string appId) : this(CreateSource(urlOrPath), new AppDescWindows())
|
||||
internal UpdateManager(string urlOrPath, string appId)
|
||||
: this(CreateSource(urlOrPath), new AppDescWindows(
|
||||
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), appId), appId))
|
||||
{
|
||||
}
|
||||
|
||||
internal UpdateManager(string urlOrPath, string appId, string localAppData)
|
||||
: this(CreateSource(urlOrPath), new AppDescWindows(Path.Combine(localAppData, appId), appId))
|
||||
{
|
||||
}
|
||||
|
||||
internal UpdateManager(string urlOrPath, string appId, string localAppData, IFileDownloader downloader)
|
||||
: this(new SimpleWebSource(urlOrPath, downloader), new AppDescWindows(Path.Combine(localAppData, appId), appId))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -44,8 +44,8 @@ namespace Squirrel.Tests
|
||||
string tempDir;
|
||||
string remotePkgDir;
|
||||
|
||||
using (Utility.WithTempDirectory(out tempDir))
|
||||
using (Utility.WithTempDirectory(out remotePkgDir)) {
|
||||
using (Utility.GetTempDirectory(out tempDir))
|
||||
using (Utility.GetTempDirectory(out remotePkgDir)) {
|
||||
IntegrationTestHelper.CreateFakeInstalledApp("0.1.0", remotePkgDir);
|
||||
var pkgs = ReleaseEntry.BuildReleasesFile(remotePkgDir);
|
||||
ReleaseEntry.WriteReleaseFile(pkgs, Path.Combine(remotePkgDir, "RELEASES"));
|
||||
@@ -73,8 +73,8 @@ namespace Squirrel.Tests
|
||||
string tempDir;
|
||||
string remotePkgDir;
|
||||
|
||||
using (Utility.WithTempDirectory(out tempDir))
|
||||
using (Utility.WithTempDirectory(out remotePkgDir)) {
|
||||
using (Utility.GetTempDirectory(out tempDir))
|
||||
using (Utility.GetTempDirectory(out remotePkgDir)) {
|
||||
IntegrationTestHelper.CreateFakeInstalledApp("0.1.0", remotePkgDir);
|
||||
var pkgs = ReleaseEntry.BuildReleasesFile(remotePkgDir);
|
||||
ReleaseEntry.WriteReleaseFile(pkgs, Path.Combine(remotePkgDir, "RELEASES"));
|
||||
@@ -110,8 +110,8 @@ namespace Squirrel.Tests
|
||||
string tempDir;
|
||||
string remotePkgDir;
|
||||
|
||||
using (Utility.WithTempDirectory(out tempDir))
|
||||
using (Utility.WithTempDirectory(out remotePkgDir)) {
|
||||
using (Utility.GetTempDirectory(out tempDir))
|
||||
using (Utility.GetTempDirectory(out remotePkgDir)) {
|
||||
IntegrationTestHelper.CreateFakeInstalledApp("0.1.0", remotePkgDir);
|
||||
var pkgs = ReleaseEntry.BuildReleasesFile(remotePkgDir);
|
||||
ReleaseEntry.WriteReleaseFile(pkgs, Path.Combine(remotePkgDir, "RELEASES"));
|
||||
@@ -147,8 +147,8 @@ namespace Squirrel.Tests
|
||||
string tempDir;
|
||||
string remotePkgDir;
|
||||
|
||||
using (Utility.WithTempDirectory(out tempDir))
|
||||
using (Utility.WithTempDirectory(out remotePkgDir)) {
|
||||
using (Utility.GetTempDirectory(out tempDir))
|
||||
using (Utility.GetTempDirectory(out remotePkgDir)) {
|
||||
IntegrationTestHelper.CreateFakeInstalledApp("0.1.0", remotePkgDir);
|
||||
var pkgs = ReleaseEntry.BuildReleasesFile(remotePkgDir);
|
||||
ReleaseEntry.WriteReleaseFile(pkgs, Path.Combine(remotePkgDir, "RELEASES"));
|
||||
@@ -186,8 +186,8 @@ namespace Squirrel.Tests
|
||||
string remotePkgDir;
|
||||
const string pkgName = "Squirrel.Installed.App";
|
||||
|
||||
using (Utility.WithTempDirectory(out tempDir))
|
||||
using (Utility.WithTempDirectory(out remotePkgDir)) {
|
||||
using (Utility.GetTempDirectory(out tempDir))
|
||||
using (Utility.GetTempDirectory(out remotePkgDir)) {
|
||||
// install 0.1.0
|
||||
IntegrationTestHelper.CreateFakeInstalledApp("0.1.0", remotePkgDir, "SquirrelInstalledAppWithDots.nuspec");
|
||||
var pkgs = ReleaseEntry.BuildReleasesFile(remotePkgDir);
|
||||
@@ -240,7 +240,7 @@ namespace Squirrel.Tests
|
||||
public void WhenNoNewReleasesAreAvailableTheListIsEmpty()
|
||||
{
|
||||
string tempDir;
|
||||
using (Utility.WithTempDirectory(out tempDir)) {
|
||||
using (Utility.GetTempDirectory(out tempDir)) {
|
||||
var appDir = Directory.CreateDirectory(Path.Combine(tempDir, "theApp"));
|
||||
var packages = Path.Combine(appDir.FullName, "packages");
|
||||
Directory.CreateDirectory(packages);
|
||||
@@ -261,7 +261,7 @@ namespace Squirrel.Tests
|
||||
public void ThrowsWhenOnlyDeltaReleasesAreAvailable()
|
||||
{
|
||||
string tempDir;
|
||||
using (Utility.WithTempDirectory(out tempDir)) {
|
||||
using (Utility.GetTempDirectory(out tempDir)) {
|
||||
var appDir = Directory.CreateDirectory(Path.Combine(tempDir, "theApp"));
|
||||
var packages = Path.Combine(appDir.FullName, "packages");
|
||||
Directory.CreateDirectory(packages);
|
||||
@@ -288,7 +288,7 @@ namespace Squirrel.Tests
|
||||
{
|
||||
string tempDir;
|
||||
|
||||
using (Utility.WithTempDirectory(out tempDir)) {
|
||||
using (Utility.GetTempDirectory(out tempDir)) {
|
||||
string appDir = Path.Combine(tempDir, "theApp");
|
||||
string packagesDir = Path.Combine(appDir, "packages");
|
||||
Directory.CreateDirectory(packagesDir);
|
||||
@@ -337,7 +337,7 @@ namespace Squirrel.Tests
|
||||
{
|
||||
string tempDir;
|
||||
|
||||
using (Utility.WithTempDirectory(out tempDir)) {
|
||||
using (Utility.GetTempDirectory(out tempDir)) {
|
||||
string appDir = Path.Combine(tempDir, "theApp");
|
||||
string packagesDir = Path.Combine(appDir, "packages");
|
||||
Directory.CreateDirectory(packagesDir);
|
||||
@@ -385,7 +385,7 @@ namespace Squirrel.Tests
|
||||
{
|
||||
string tempDir;
|
||||
|
||||
using (Utility.WithTempDirectory(out tempDir)) {
|
||||
using (Utility.GetTempDirectory(out tempDir)) {
|
||||
string appDir = Path.Combine(tempDir, "theApp");
|
||||
string packagesDir = Path.Combine(appDir, "packages");
|
||||
Directory.CreateDirectory(packagesDir);
|
||||
@@ -435,7 +435,7 @@ namespace Squirrel.Tests
|
||||
{
|
||||
string tempDir;
|
||||
|
||||
using (Utility.WithTempDirectory(out tempDir)) {
|
||||
using (Utility.GetTempDirectory(out tempDir)) {
|
||||
string appDir = Path.Combine(tempDir, "theApp");
|
||||
string packagesDir = Path.Combine(appDir, "packages");
|
||||
Directory.CreateDirectory(packagesDir);
|
||||
@@ -485,7 +485,7 @@ namespace Squirrel.Tests
|
||||
public async Task CreateFullPackagesFromDeltaSmokeTest()
|
||||
{
|
||||
string tempDir;
|
||||
using (Utility.WithTempDirectory(out tempDir)) {
|
||||
using (Utility.GetTempDirectory(out tempDir)) {
|
||||
string appDir = Path.Combine(tempDir, "theApp");
|
||||
string packagesDir = Path.Combine(appDir, "packages");
|
||||
Directory.CreateDirectory(packagesDir);
|
||||
@@ -516,8 +516,8 @@ namespace Squirrel.Tests
|
||||
string remotePkgPath;
|
||||
string path;
|
||||
|
||||
using (Utility.WithTempDirectory(out path)) {
|
||||
using (Utility.WithTempDirectory(out remotePkgPath))
|
||||
using (Utility.GetTempDirectory(out path)) {
|
||||
using (Utility.GetTempDirectory(out remotePkgPath))
|
||||
using (var mgr = new UpdateManager(remotePkgPath, "theApp", path)) {
|
||||
IntegrationTestHelper.CreateFakeInstalledApp("1.0.0.1", remotePkgPath);
|
||||
await mgr.FullInstall();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using Squirrel.CommandLine;
|
||||
using Xunit.Abstractions;
|
||||
using Xunit.Sdk;
|
||||
|
||||
@@ -14,9 +15,9 @@ namespace Squirrel.Tests
|
||||
{
|
||||
// Place initialization code here
|
||||
var baseDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase.Replace("file:///", ""));
|
||||
HelperExe.AddSearchPath(Path.Combine(baseDir, "..", "..", "..", "..", "vendor"));
|
||||
HelperExe.AddSearchPath(Path.Combine(baseDir, "..", "..", "..", "..", "vendor", "7zip"));
|
||||
HelperExe.AddSearchPath(Path.Combine(baseDir, "..", "..", "..", "..", "vendor", "wix"));
|
||||
HelperFile.AddSearchPath(Path.Combine(baseDir, "..", "..", "..", "..", "vendor"));
|
||||
HelperFile.AddSearchPath(Path.Combine(baseDir, "..", "..", "..", "..", "vendor", "7zip"));
|
||||
HelperFile.AddSearchPath(Path.Combine(baseDir, "..", "..", "..", "..", "vendor", "wix"));
|
||||
}
|
||||
|
||||
public new void Dispose()
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net48</TargetFramework>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Description>Squirrel.Tests</Description>
|
||||
<Title>Squirrel.Tests</Title>
|
||||
<IsPackable>false</IsPackable>
|
||||
@@ -13,25 +13,16 @@
|
||||
<AssemblyOriginatorKeyFile>..\Squirrel.snk</AssemblyOriginatorKeyFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="..\src\Squirrel.CommandLine\NugetConsole.cs" Link="TestHelpers\NugetConsole.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
|
||||
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" PrivateAssets="All" />
|
||||
<PackageReference Include="System.IO.Packaging" Version="6.0.0" />
|
||||
<PackageReference Include="NuGet.Commands" Version="6.1.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\src\Squirrel\Squirrel.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="System.Net.Http" />
|
||||
<ProjectReference Include="..\src\Squirrel.CommandLine\Squirrel.CommandLine.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -11,6 +11,7 @@ using System.Text;
|
||||
using SharpCompress.Archives.Zip;
|
||||
using SharpCompress.Readers;
|
||||
using SharpCompress.Common;
|
||||
using Squirrel.CommandLine;
|
||||
|
||||
namespace Squirrel.Tests.TestHelpers
|
||||
{
|
||||
@@ -63,7 +64,7 @@ namespace Squirrel.Tests.TestHelpers
|
||||
static object gate = 42;
|
||||
public static IDisposable WithFakeInstallDirectory(string packageFileName, out string path)
|
||||
{
|
||||
var ret = Utility.WithTempDirectory(out path);
|
||||
var ret = Utility.GetTempDirectory(out path);
|
||||
|
||||
File.Copy(GetPath("fixtures", packageFileName), Path.Combine(path, packageFileName));
|
||||
var rp = ReleaseEntry.GenerateFromFile(Path.Combine(path, packageFileName));
|
||||
@@ -78,7 +79,7 @@ namespace Squirrel.Tests.TestHelpers
|
||||
|
||||
nuspecFile = nuspecFile ?? "SquirrelInstalledApp.nuspec";
|
||||
|
||||
using (var clearTemp = Utility.WithTempDirectory(out targetDir)) {
|
||||
using (var clearTemp = Utility.GetTempDirectory(out targetDir)) {
|
||||
var nuspec = File.ReadAllText(IntegrationTestHelper.GetPath("fixtures", nuspecFile), Encoding.UTF8);
|
||||
var nuspecPath = Path.Combine(targetDir, nuspecFile);
|
||||
|
||||
@@ -91,7 +92,7 @@ namespace Squirrel.Tests.TestHelpers
|
||||
IntegrationTestHelper.GetPath("fixtures", "NotSquirrelAwareApp.exe"),
|
||||
Path.Combine(targetDir, "NotSquirrelAwareApp.exe"));
|
||||
|
||||
new SquirrelCli.NugetConsole().Pack(nuspecPath, targetDir, targetDir);
|
||||
new NugetConsole().Pack(nuspecPath, targetDir, targetDir);
|
||||
|
||||
var di = new DirectoryInfo(targetDir);
|
||||
var pkg = di.EnumerateFiles("*.nupkg").First();
|
||||
@@ -114,7 +115,7 @@ namespace Squirrel.Tests.TestHelpers
|
||||
|
||||
public static IDisposable WithFakeAlreadyInstalledApp(string zipFile, out string path)
|
||||
{
|
||||
var ret = Utility.WithTempDirectory(out path);
|
||||
var ret = Utility.GetTempDirectory(out path);
|
||||
|
||||
// NB: Apparently Ionic.Zip is perfectly content to extract a Zip
|
||||
// file that doesn't actually exist, without failing.
|
||||
|
||||
@@ -26,8 +26,8 @@ namespace Squirrel.Tests
|
||||
string remotePkgPath;
|
||||
string path;
|
||||
|
||||
using (Utility.WithTempDirectory(out path)) {
|
||||
using (Utility.WithTempDirectory(out remotePkgPath))
|
||||
using (Utility.GetTempDirectory(out path)) {
|
||||
using (Utility.GetTempDirectory(out remotePkgPath))
|
||||
using (var mgr = new UpdateManager(remotePkgPath, "theApp", path)) {
|
||||
IntegrationTestHelper.CreateFakeInstalledApp("1.0.0.1", remotePkgPath);
|
||||
await mgr.FullInstall();
|
||||
@@ -62,7 +62,7 @@ namespace Squirrel.Tests
|
||||
public async Task UpdateLocalReleasesSmokeTest()
|
||||
{
|
||||
string tempDir;
|
||||
using (Utility.WithTempDirectory(out tempDir)) {
|
||||
using (Utility.GetTempDirectory(out tempDir)) {
|
||||
var appDir = Path.Combine(tempDir, "theApp");
|
||||
var packageDir = Directory.CreateDirectory(Path.Combine(appDir, "packages"));
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace Squirrel.Tests
|
||||
public async Task InitialInstallSmokeTest()
|
||||
{
|
||||
string tempDir;
|
||||
using (Utility.WithTempDirectory(out tempDir)) {
|
||||
using (Utility.GetTempDirectory(out tempDir)) {
|
||||
var remotePackageDir = Directory.CreateDirectory(Path.Combine(tempDir, "remotePackages"));
|
||||
var localAppDir = Path.Combine(tempDir, "theApp");
|
||||
|
||||
@@ -116,7 +116,7 @@ namespace Squirrel.Tests
|
||||
public async Task SpecialCharactersInitialInstallTest()
|
||||
{
|
||||
string tempDir;
|
||||
using (Utility.WithTempDirectory(out tempDir)) {
|
||||
using (Utility.GetTempDirectory(out tempDir)) {
|
||||
var remotePackageDir = Directory.CreateDirectory(Path.Combine(tempDir, "remotePackages"));
|
||||
var localAppDir = Path.Combine(tempDir, "theApp");
|
||||
|
||||
@@ -144,7 +144,7 @@ namespace Squirrel.Tests
|
||||
public async Task WhenBothFilesAreInSyncNoUpdatesAreApplied()
|
||||
{
|
||||
string tempDir;
|
||||
using (Utility.WithTempDirectory(out tempDir)) {
|
||||
using (Utility.GetTempDirectory(out tempDir)) {
|
||||
var appDir = Path.Combine(tempDir, "theApp");
|
||||
var localPackages = Path.Combine(appDir, "packages");
|
||||
var remotePackages = Path.Combine(tempDir, "releases");
|
||||
@@ -180,7 +180,7 @@ namespace Squirrel.Tests
|
||||
public async Task WhenRemoteReleasesDoNotHaveDeltasNoUpdatesAreApplied()
|
||||
{
|
||||
string tempDir;
|
||||
using (Utility.WithTempDirectory(out tempDir)) {
|
||||
using (Utility.GetTempDirectory(out tempDir)) {
|
||||
var appDir = Path.Combine(tempDir, "theApp");
|
||||
var localPackages = Path.Combine(appDir, "packages");
|
||||
var remotePackages = Path.Combine(tempDir, "releases");
|
||||
@@ -222,7 +222,7 @@ namespace Squirrel.Tests
|
||||
public async Task WhenTwoRemoteUpdatesAreAvailableChoosesDeltaVersion()
|
||||
{
|
||||
string tempDir;
|
||||
using (Utility.WithTempDirectory(out tempDir)) {
|
||||
using (Utility.GetTempDirectory(out tempDir)) {
|
||||
var appDir = Path.Combine(tempDir, "theApp");
|
||||
var localPackages = Path.Combine(appDir, "packages");
|
||||
var remotePackages = Path.Combine(tempDir, "releases");
|
||||
@@ -262,7 +262,7 @@ namespace Squirrel.Tests
|
||||
public async Task WhenFolderDoesNotExistThrowHelpfulError()
|
||||
{
|
||||
string tempDir;
|
||||
using (Utility.WithTempDirectory(out tempDir)) {
|
||||
using (Utility.GetTempDirectory(out tempDir)) {
|
||||
var directory = Path.Combine(tempDir, "missing-folder");
|
||||
var fixture = new UpdateManager(directory, "MyAppName");
|
||||
|
||||
@@ -276,7 +276,7 @@ namespace Squirrel.Tests
|
||||
public async Task WhenReleasesFileDoesntExistThrowACustomError()
|
||||
{
|
||||
string tempDir;
|
||||
using (Utility.WithTempDirectory(out tempDir)) {
|
||||
using (Utility.GetTempDirectory(out tempDir)) {
|
||||
var fixture = new UpdateManager(tempDir, "MyAppName");
|
||||
|
||||
using (fixture) {
|
||||
@@ -289,7 +289,7 @@ namespace Squirrel.Tests
|
||||
public async Task WhenReleasesFileIsBlankThrowAnException()
|
||||
{
|
||||
string tempDir;
|
||||
using (Utility.WithTempDirectory(out tempDir)) {
|
||||
using (Utility.GetTempDirectory(out tempDir)) {
|
||||
var fixture = new UpdateManager(tempDir, "MyAppName");
|
||||
File.WriteAllText(Path.Combine(tempDir, "RELEASES"), "");
|
||||
|
||||
@@ -311,7 +311,7 @@ namespace Squirrel.Tests
|
||||
[Fact]
|
||||
public void IsInstalledHandlesInvalidDirectoryStructure()
|
||||
{
|
||||
using (Utility.WithTempDirectory(out var tempDir)) {
|
||||
using (Utility.GetTempDirectory(out var tempDir)) {
|
||||
Directory.CreateDirectory(Path.Combine(tempDir, "theApp"));
|
||||
Directory.CreateDirectory(Path.Combine(tempDir, "theApp", "app-1.0.1"));
|
||||
Directory.CreateDirectory(Path.Combine(tempDir, "theApp", "wrongDir"));
|
||||
|
||||
@@ -135,7 +135,7 @@ namespace Squirrel.Tests
|
||||
public void CanDeleteDeepRecursiveDirectoryStructure()
|
||||
{
|
||||
string tempDir;
|
||||
using (Utility.WithTempDirectory(out tempDir)) {
|
||||
using (Utility.GetTempDirectory(out tempDir)) {
|
||||
for (var i = 0; i < 50; i++) {
|
||||
var directory = Path.Combine(tempDir, newId());
|
||||
CreateSampleDirectory(directory);
|
||||
@@ -161,7 +161,7 @@ namespace Squirrel.Tests
|
||||
public void CreateFakePackageSmokeTest()
|
||||
{
|
||||
string path;
|
||||
using (Utility.WithTempDirectory(out path)) {
|
||||
using (Utility.GetTempDirectory(out path)) {
|
||||
var output = IntegrationTestHelper.CreateFakeInstalledApp("0.3.0", path);
|
||||
Assert.True(File.Exists(output));
|
||||
}
|
||||
@@ -205,7 +205,7 @@ namespace Squirrel.Tests
|
||||
var dl = Utility.CreateDefaultDownloader();
|
||||
|
||||
List<int> prog = new List<int>();
|
||||
using (Utility.WithTempFile(out var tempPath))
|
||||
using (Utility.GetTempFileName(out var tempPath))
|
||||
dl.DownloadFile(testUrl, tempPath, prog.Add).Wait();
|
||||
|
||||
Assert.True(prog.Count > 10);
|
||||
|
||||
Reference in New Issue
Block a user