Fix failing tests

This commit is contained in:
Caelan Sayler
2024-01-15 13:12:57 +00:00
parent 120facd6f3
commit 98bfc22898
15 changed files with 34 additions and 128 deletions

View File

@@ -37,7 +37,7 @@ public abstract class SourceRepository<TDown, TSource> : DownRepository<TDown>
protected override Task SaveEntryToFileAsync(TDown options, ReleaseEntry entry, string filePath) protected override Task SaveEntryToFileAsync(TDown options, ReleaseEntry entry, string filePath)
{ {
var source = CreateSource(options); var source = CreateSource(options);
return source.DownloadReleaseEntry(entry, filePath, (i) => { }, logger: Log); return source.DownloadReleaseEntry(Log, entry, filePath, (i) => { });
} }
public abstract TSource CreateSource(TDown options); public abstract TSource CreateSource(TDown options);

View File

@@ -76,9 +76,6 @@ namespace Velopack.Locators
/// <inheritdoc /> /// <inheritdoc />
public override string Channel { public override string Channel {
get { get {
if (_channel == null) {
throw new NotSupportedException("AppContentDir is not supported in this test implementation.");
}
return _channel; return _channel;
} }
} }

View File

@@ -4,6 +4,7 @@ using System.Linq;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Velopack.Json; using Velopack.Json;
namespace Velopack.Sources namespace Velopack.Sources
@@ -133,7 +134,7 @@ namespace Velopack.Sources
} }
/// <inheritdoc /> /// <inheritdoc />
public async Task<ReleaseEntry[]> GetReleaseFeed(string channel = null, Guid? stagingId = null, ReleaseEntryName latestLocalRelease = null, ILogger logger = null) public async Task<ReleaseEntry[]> GetReleaseFeed(ILogger logger, string channel = null, Guid? stagingId = null, ReleaseEntryName latestLocalRelease = null)
{ {
if (String.IsNullOrWhiteSpace(AccessToken)) if (String.IsNullOrWhiteSpace(AccessToken))
logger.Warn("No GitHub access token provided. Unauthenticated requests will be limited to 60 per hour."); logger.Warn("No GitHub access token provided. Unauthenticated requests will be limited to 60 per hour.");
@@ -161,7 +162,7 @@ namespace Velopack.Sources
} }
/// <inheritdoc /> /// <inheritdoc />
public async Task DownloadReleaseEntry(ReleaseEntry releaseEntry, string localFile, Action<int> progress, ILogger logger = null) public async Task DownloadReleaseEntry(ILogger logger, ReleaseEntry releaseEntry, string localFile, Action<int> progress)
{ {
if (releaseEntry is GithubReleaseEntry githubEntry) { if (releaseEntry is GithubReleaseEntry githubEntry) {
// this might be a browser url or an api url (depending on whether we have a AccessToken or not) // this might be a browser url or an api url (depending on whether we have a AccessToken or not)

View File

@@ -165,7 +165,7 @@ namespace Velopack.Sources
} }
/// <inheritdoc /> /// <inheritdoc />
public async Task DownloadReleaseEntry(ReleaseEntry releaseEntry, string localFile, Action<int> progress, ILogger logger = null) public async Task DownloadReleaseEntry(ILogger logger, ReleaseEntry releaseEntry, string localFile, Action<int> progress)
{ {
if (releaseEntry is GitlabReleaseEntry githubEntry) { if (releaseEntry is GitlabReleaseEntry githubEntry) {
// this might be a browser url or an api url (depending on whether we have a AccessToken or not) // this might be a browser url or an api url (depending on whether we have a AccessToken or not)
@@ -178,7 +178,7 @@ namespace Velopack.Sources
} }
/// <inheritdoc /> /// <inheritdoc />
public async Task<ReleaseEntry[]> GetReleaseFeed(string channel = null, Guid? stagingId = null, ReleaseEntryName latestLocalRelease = null, ILogger logger = null) public async Task<ReleaseEntry[]> GetReleaseFeed(ILogger logger, string channel = null, Guid? stagingId = null, ReleaseEntryName latestLocalRelease = null)
{ {
var releases = await GetReleases(UpcomingRelease).ConfigureAwait(false); var releases = await GetReleases(UpcomingRelease).ConfigureAwait(false);
if (releases == null || releases.Count() == 0) if (releases == null || releases.Count() == 0)

View File

@@ -27,7 +27,7 @@ namespace Velopack.Sources
/// <param name="logger">The logger to use for any diagnostic messages.</param> /// <param name="logger">The logger to use for any diagnostic messages.</param>
/// <returns>An array of <see cref="ReleaseEntry"/> objects that are available for download /// <returns>An array of <see cref="ReleaseEntry"/> objects that are available for download
/// and are applicable to this user.</returns> /// and are applicable to this user.</returns>
Task<ReleaseEntry[]> GetReleaseFeed(string channel = null, Guid? stagingId = null, ReleaseEntryName latestLocalRelease = null, ILogger logger = null); Task<ReleaseEntry[]> GetReleaseFeed(ILogger logger, string channel = null, Guid? stagingId = null, ReleaseEntryName latestLocalRelease = null);
/// <summary> /// <summary>
/// Download the specified <see cref="ReleaseEntry"/> to the provided local file path. /// Download the specified <see cref="ReleaseEntry"/> to the provided local file path.
@@ -38,6 +38,6 @@ namespace Velopack.Sources
/// <param name="progress">This delegate will be executed with values from 0-100 as the /// <param name="progress">This delegate will be executed with values from 0-100 as the
/// download is being processed.</param> /// download is being processed.</param>
/// <param name="logger">The logger to use for any diagnostic messages.</param> /// <param name="logger">The logger to use for any diagnostic messages.</param>
Task DownloadReleaseEntry(ReleaseEntry releaseEntry, string localFile, Action<int> progress, ILogger logger = null); Task DownloadReleaseEntry(ILogger logger, ReleaseEntry releaseEntry, string localFile, Action<int> progress);
} }
} }

View File

@@ -4,6 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
namespace Velopack.Sources namespace Velopack.Sources
{ {
@@ -23,7 +24,7 @@ namespace Velopack.Sources
} }
/// <inheritdoc /> /// <inheritdoc />
public Task<ReleaseEntry[]> GetReleaseFeed(string channel = null, Guid? stagingId = null, ReleaseEntryName latestLocalRelease = null, ILogger logger = null) public Task<ReleaseEntry[]> GetReleaseFeed(ILogger logger, string channel = null, Guid? stagingId = null, ReleaseEntryName latestLocalRelease = null)
{ {
if (!BaseDirectory.Exists) if (!BaseDirectory.Exists)
throw new Exception($"The local update directory '{BaseDirectory.FullName}' does not exist."); throw new Exception($"The local update directory '{BaseDirectory.FullName}' does not exist.");
@@ -48,7 +49,7 @@ namespace Velopack.Sources
} }
/// <inheritdoc /> /// <inheritdoc />
public Task DownloadReleaseEntry(ReleaseEntry releaseEntry, string localFile, Action<int> progress, ILogger logger = null) public Task DownloadReleaseEntry(ILogger logger, ReleaseEntry releaseEntry, string localFile, Action<int> progress)
{ {
var releasePath = Path.Combine(BaseDirectory.FullName, releaseEntry.OriginalFilename); var releasePath = Path.Combine(BaseDirectory.FullName, releaseEntry.OriginalFilename);
if (!File.Exists(releasePath)) if (!File.Exists(releasePath))

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
namespace Velopack.Sources namespace Velopack.Sources
{ {
@@ -32,7 +33,7 @@ namespace Velopack.Sources
} }
/// <inheritdoc /> /// <inheritdoc />
public async Task<ReleaseEntry[]> GetReleaseFeed(string channel = null, Guid? stagingId = null, ReleaseEntryName latestLocalRelease = null, ILogger logger = null) public async Task<ReleaseEntry[]> GetReleaseFeed(ILogger logger, string channel = null, Guid? stagingId = null, ReleaseEntryName latestLocalRelease = null)
{ {
var uri = Utility.AppendPathToUri(BaseUri, Utility.GetReleasesFileName(channel)); var uri = Utility.AppendPathToUri(BaseUri, Utility.GetReleasesFileName(channel));
var args = new Dictionary<string, string>(); var args = new Dictionary<string, string>();
@@ -61,7 +62,7 @@ namespace Velopack.Sources
} }
/// <inheritdoc /> /// <inheritdoc />
public async Task DownloadReleaseEntry(ReleaseEntry releaseEntry, string localFile, Action<int> progress, ILogger logger = null) public async Task DownloadReleaseEntry(ILogger logger, ReleaseEntry releaseEntry, string localFile, Action<int> progress)
{ {
if (releaseEntry == null) throw new ArgumentNullException(nameof(releaseEntry)); if (releaseEntry == null) throw new ArgumentNullException(nameof(releaseEntry));
if (localFile == null) throw new ArgumentNullException(nameof(localFile)); if (localFile == null) throw new ArgumentNullException(nameof(localFile));

View File

@@ -112,8 +112,8 @@ namespace Velopack
var latestLocalFull = Locator.GetLatestLocalFullPackage(); var latestLocalFull = Locator.GetLatestLocalFullPackage();
Log.Debug("Retrieving latest release feed."); Log.Debug("Retrieving latest release feed.");
var channel = Channel ?? Locator.Channel; var channel = Channel ?? Locator.Channel ?? VelopackRuntimeInfo.SystemOs.GetOsShortName();
var feed = await Source.GetReleaseFeed(channel, betaId, latestLocalFull?.Identity, Log).ConfigureAwait(false); var feed = await Source.GetReleaseFeed(Log, channel, betaId, latestLocalFull?.Identity).ConfigureAwait(false);
var latestRemoteFull = feed.Where(r => !r.IsDelta).MaxBy(x => x.Version).FirstOrDefault(); var latestRemoteFull = feed.Where(r => !r.IsDelta).MaxBy(x => x.Version).FirstOrDefault();
if (latestRemoteFull == null) { if (latestRemoteFull == null) {
@@ -257,7 +257,7 @@ namespace Velopack
Log.Info($"Downloading full release ({targetRelease.OriginalFilename})"); Log.Info($"Downloading full release ({targetRelease.OriginalFilename})");
File.Delete(incompleteFile); File.Delete(incompleteFile);
await Source.DownloadReleaseEntry(targetRelease, incompleteFile, reportProgress).ConfigureAwait(false); await Source.DownloadReleaseEntry(Log, targetRelease, incompleteFile, reportProgress).ConfigureAwait(false);
Log.Info("Verifying package checksum..."); Log.Info("Verifying package checksum...");
VerifyPackageChecksum(targetRelease, incompleteFile); VerifyPackageChecksum(targetRelease, incompleteFile);
File.Delete(completeFile); File.Delete(completeFile);
@@ -392,7 +392,7 @@ namespace Velopack
var targetFile = Path.Combine(packagesDirectory, x.OriginalFilename); var targetFile = Path.Combine(packagesDirectory, x.OriginalFilename);
double component = 0; double component = 0;
Log.Debug($"Downloading delta version {x.Version}"); Log.Debug($"Downloading delta version {x.Version}");
await Source.DownloadReleaseEntry(x, targetFile, p => { await Source.DownloadReleaseEntry(Log, x, targetFile, p => {
lock (progress) { lock (progress) {
current -= component; current -= component;
component = toIncrement / 100.0 * p; component = toIncrement / 100.0 * p;

View File

@@ -97,17 +97,6 @@ public class S3UploadCommandTests : S3CommandTests<S3UploadCommand>
{ {
public override bool ShouldBeNonEmptyReleaseDir => true; 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] //[Fact]
//public void KeepMaxReleases_WithNumber_ParsesValue() //public void KeepMaxReleases_WithNumber_ParsesValue()
//{ //{

View File

@@ -157,8 +157,8 @@ This is just a _test_!
Assert.Equal(notesContent.Trim().ReplaceLineEndings("\n"), newRelease.Body.Trim()); Assert.Equal(notesContent.Trim().ReplaceLineEndings("\n"), newRelease.Body.Trim());
// update // update
var source = new GithubSource(GITHUB_REPOURL, GITHUB_TOKEN, false, logger: logger); var source = new GithubSource(GITHUB_REPOURL, GITHUB_TOKEN, false);
var releases = source.GetReleaseFeed().GetAwaiterResult(); var releases = source.GetReleaseFeed(logger: logger).GetAwaiterResult();
var ghrel = releases.Select(r => (GithubReleaseEntry) r).ToArray(); var ghrel = releases.Select(r => (GithubReleaseEntry) r).ToArray();
Assert.Equal(2, ghrel.Length); Assert.Equal(2, ghrel.Length);

View File

@@ -1,44 +0,0 @@
using System.Xml;
using Velopack.NuGet;
namespace Velopack.Tests
{
public class ContentTypeTests
{
[Theory]
[InlineData("basic.xml", "basic-merged.xml")]
[InlineData("complex.xml", "complex-merged.xml")]
public void MergeContentTypes(string inputFileName, string expectedFileName)
{
var inputFile = PathHelper.GetFixture("content-types", inputFileName);
var expectedFile = PathHelper.GetFixture("content-types", expectedFileName);
var tempFile = Path.GetTempFileName() + ".xml";
var expected = new XmlDocument();
expected.Load(expectedFile);
var existingTypes = GetContentTypes(expected);
try {
File.Copy(inputFile, tempFile);
var actual = new XmlDocument();
actual.Load(tempFile);
ContentType.Merge(actual);
var actualTypes = GetContentTypes(actual);
Assert.Equal(existingTypes, actualTypes);
} finally {
File.Delete(tempFile);
}
}
static IEnumerable<XmlElement> GetContentTypes(XmlNode doc)
{
var expectedTypesElement = doc.FirstChild.NextSibling;
return expectedTypesElement.ChildNodes.OfType<XmlElement>();
}
}
}

View File

@@ -146,44 +146,7 @@ namespace Velopack.Tests
var old = OldReleaseEntry.ParseReleaseEntry(releaseEntry); var old = OldReleaseEntry.ParseReleaseEntry(releaseEntry);
Assert.Equal(new NuGetVersion(major, minor, patch, revision, prerelease, null), new NuGetVersion(old.Version.ToString())); Assert.Equal(new NuGetVersion(major, minor, patch, revision, prerelease, null), new NuGetVersion(old.Version.ToString()));
Assert.Equal(isDelta, old.IsDelta); Assert.Equal(isDelta, old.IsDelta);
} }
[Theory]
[InlineData("0900000000000000000000000000000000000000 MyCoolApp-1.2.3-beta1-win7-x64.nupkg 123", 1, 2, 3, 0, "beta1", "win7-x64", false)]
[InlineData("0010000000000000000000000000000000000000 MyCoolApp-1.2.3-beta1-win7-x64-full.nupkg 123", 1, 2, 3, 0, "beta1", "win7-x64", false)]
[InlineData("0020000000000000000000000000000000000000 MyCoolApp-1.2.3-beta1-win7-x64-delta.nupkg 123", 1, 2, 3, 0, "beta1", "win7-x64", true)]
[InlineData("0030000000000000000000000000000000000000 MyCoolApp-1.2.3-osx-full.nupkg 123", 1, 2, 3, 0, "", "osx", false)]
[InlineData("0030000000000000000000000000000000000000 MyCoolApp-1.2.3-osx-arm64-full.nupkg 123", 1, 2, 3, 0, "", "osx-arm64", false)]
[InlineData("0030000000000000000000000000000000000000 MyCoolApp-1.2.3-hello-osx-arm64-full.nupkg 123", 1, 2, 3, 0, "hello", "osx-arm64", false)]
[InlineData("0030000000000000000000000000000000000000 MyCoolApp-1.2.3-x86-full.nupkg 123", 1, 2, 3, 0, "", "x86", false)]
public void ParseVersionWithRidTest(string releaseEntry, int major, int minor, int patch, int revision, string prerelease, string rid, bool isDelta)
{
var fixture = ReleaseEntry.ParseReleaseEntry(releaseEntry);
Assert.Equal(new NuGetVersion(major, minor, patch, revision, prerelease, null), fixture.Version);
Assert.Equal(isDelta, fixture.IsDelta);
if (!String.IsNullOrEmpty(rid))
Assert.Equal(RID.Parse(rid), fixture.Rid);
var old = OldReleaseEntry.ParseReleaseEntry(releaseEntry);
var legacyPre = !String.IsNullOrEmpty(prerelease) && !String.IsNullOrEmpty(rid) ? $"{prerelease}-{rid}" : String.IsNullOrEmpty(prerelease) ? rid : prerelease;
Assert.Equal(new NuGetVersion(major, minor, patch, revision, legacyPre, null), new NuGetVersion(old.Version.ToString()));
Assert.Equal(isDelta, old.IsDelta);
}
[Theory]
[InlineData("0030000000000000000000000000000000000000 MyCoolApp-1.2.3-beta.22-win7-x64-full.nupkg 123", 1, 2, 3, 0, "beta.22", "win7-x64", false)]
[InlineData("0030000000000000000000000000000000000000 MyCoolApp-1.2.3-beta.22-x64-full.nupkg 123", 1, 2, 3, 0, "beta.22", "x64", false)]
[InlineData("0030000000000000000000000000000000000000 MyCoolApp-1.2.3-beta.22-win-full.nupkg 123", 1, 2, 3, 0, "beta.22", "win", false)]
[InlineData("0030000000000000000000000000000000000000 MyCoolApp-1.2.3-hello.55-osx-arm64-full.nupkg 123", 1, 2, 3, 0, "hello.55", "osx-arm64", false)]
[InlineData("0030000000000000000000000000000000000000 MyCoolApp-1.2.3-hello.55-full.nupkg 123", 1, 2, 3, 0, "hello.55", "", false)]
public void ParseVersionWithSemVer2(string releaseEntry, int major, int minor, int patch, int revision, string prerelease, string rid, bool isDelta)
{
var fixture = ReleaseEntry.ParseReleaseEntry(releaseEntry);
Assert.Equal(new NuGetVersion(major, minor, patch, revision, prerelease, null), fixture.Version);
Assert.Equal(isDelta, fixture.IsDelta);
if (!String.IsNullOrEmpty(rid))
Assert.Equal(RID.Parse(rid), fixture.Rid);
}
[Theory] [Theory]
[InlineData("0000000000000000000000000000000000000000 MyCool-App-1.2.nupkg 123", "MyCool-App")] [InlineData("0000000000000000000000000000000000000000 MyCool-App-1.2.nupkg 123", "MyCool-App")]
@@ -218,8 +181,6 @@ namespace Velopack.Tests
[InlineData("0000000000000000000000000000000000000000 MyCoolApp-1.2-full.nupkg 123 # 90%", 1, 2, 0, 0, "", "", false, 0.9f)] [InlineData("0000000000000000000000000000000000000000 MyCoolApp-1.2-full.nupkg 123 # 90%", 1, 2, 0, 0, "", "", false, 0.9f)]
[InlineData("0000000000000000000000000000000000000000 MyCoolApp-1.2-delta.nupkg 123", 1, 2, 0, 0, "", "", true, null)] [InlineData("0000000000000000000000000000000000000000 MyCoolApp-1.2-delta.nupkg 123", 1, 2, 0, 0, "", "", true, null)]
[InlineData("0000000000000000000000000000000000000000 MyCoolApp-1.2-delta.nupkg 123 # 5%", 1, 2, 0, 0, "", "", true, 0.05f)] [InlineData("0000000000000000000000000000000000000000 MyCoolApp-1.2-delta.nupkg 123 # 5%", 1, 2, 0, 0, "", "", true, 0.05f)]
[InlineData("0000000000000000000000000000000000000000 MyCoolApp-1.2-win7-x64-delta.nupkg 123", 1, 2, 0, 0, "", "win7-x64", true, null)]
[InlineData("0000000000000000000000000000000000000000 MyCoolApp-1.2-win7-x64-full.nupkg 123 # 5%", 1, 2, 0, 0, "", "win7-x64", false, 0.05f)]
public void ParseStagingPercentageTest(string releaseEntry, int major, int minor, int patch, int revision, string prerelease, string rid, bool isDelta, float? stagingPercentage) public void ParseStagingPercentageTest(string releaseEntry, int major, int minor, int patch, int revision, string prerelease, string rid, bool isDelta, float? stagingPercentage)
{ {
var fixture = ReleaseEntry.ParseReleaseEntry(releaseEntry); var fixture = ReleaseEntry.ParseReleaseEntry(releaseEntry);

View File

@@ -34,7 +34,7 @@ namespace Velopack.Tests
PathHelper.CopyFixtureTo("AvaloniaCrossPlat-1.0.15-win-full.nupkg", packages.FullName); PathHelper.CopyFixtureTo("AvaloniaCrossPlat-1.0.15-win-full.nupkg", packages.FullName);
PathHelper.CopyFixtureTo(exeName, current.FullName); PathHelper.CopyFixtureTo(exeName, current.FullName);
var locator = new TestVelopackLocator("AvaloniaCrossPlat", "1.0.0", packages.FullName, current.FullName, rootDir, null, logger); var locator = new TestVelopackLocator("AvaloniaCrossPlat", "1.0.0", packages.FullName, current.FullName, rootDir, null, null, logger);
var sh = new Shortcuts(logger, locator); var sh = new Shortcuts(logger, locator);
var flag = ShortcutLocation.StartMenuRoot | ShortcutLocation.Desktop; var flag = ShortcutLocation.StartMenuRoot | ShortcutLocation.Desktop;
sh.DeleteShortcuts(exeName, flag); sh.DeleteShortcuts(exeName, flag);

View File

@@ -11,7 +11,7 @@ namespace Velopack.Tests.TestHelpers
public FakeFixtureRepository(string pkgId, bool mockLatestFullVer, string channel = null) public FakeFixtureRepository(string pkgId, bool mockLatestFullVer, string channel = null)
{ {
_releasesName = SourceBase.GetReleasesFileNameImpl(channel); _releasesName = Utility.GetReleasesFileName(channel);
_pkgId = pkgId; _pkgId = pkgId;
var releases = ReleaseEntry.BuildReleasesFile(PathHelper.GetFixturesDir(), false) var releases = ReleaseEntry.BuildReleasesFile(PathHelper.GetFixturesDir(), false)
.Where(r => r.OriginalFilename.StartsWith(_pkgId)) .Where(r => r.OriginalFilename.StartsWith(_pkgId))
@@ -24,7 +24,7 @@ namespace Velopack.Tests.TestHelpers
// our fixtures don't have a full package for the latest version, we expect the tests to generate this file // our fixtures don't have a full package for the latest version, we expect the tests to generate this file
if (maxfullVer.Version < maxDeltaVer.Version) { if (maxfullVer.Version < maxDeltaVer.Version) {
var name = new ReleaseEntryName(maxfullVer.PackageId, maxDeltaVer.Version, false, maxfullVer.Rid); var name = new ReleaseEntryName(maxfullVer.PackageId, maxDeltaVer.Version, false);
releases.Add(new ReleaseEntry("0000000000000000000000000000000000000000", name.ToFileName(), maxfullVer.Filesize)); releases.Add(new ReleaseEntry("0000000000000000000000000000000000000000", name.ToFileName(), maxfullVer.Filesize));
} }
} }

View File

@@ -68,7 +68,7 @@ namespace Velopack.Tests
"""; """;
var downloader = new FakeDownloader() { MockedResponseBytes = Encoding.UTF8.GetBytes(releases) }; var downloader = new FakeDownloader() { MockedResponseBytes = Encoding.UTF8.GetBytes(releases) };
var locator = new TestVelopackLocator("MyCoolApp", "1.0.0", tempPath, logger); var locator = new TestVelopackLocator("MyCoolApp", "1.0.0", tempPath, logger);
var um = new UpdateManager(new SimpleWebSource("http://any.com", "hello", downloader, logger), logger, locator); var um = new UpdateManager(new SimpleWebSource("http://any.com", downloader), "hello", logger, locator);
var info = um.CheckForUpdates(); var info = um.CheckForUpdates();
Assert.NotNull(info); Assert.NotNull(info);
Assert.True(new SemanticVersion(1, 1, 0) == info.TargetFullRelease.Version); Assert.True(new SemanticVersion(1, 1, 0) == info.TargetFullRelease.Version);
@@ -110,7 +110,7 @@ namespace Velopack.Tests
using var _1 = Utility.GetTempDirectory(out var tempPath); using var _1 = Utility.GetTempDirectory(out var tempPath);
var locator = new TestVelopackLocator("MyCoolApp", "1.0.0", tempPath, logger); var locator = new TestVelopackLocator("MyCoolApp", "1.0.0", tempPath, logger);
var source = new GithubSource("https://github.com/caesay/SquirrelCustomLauncherTestApp", null, false); var source = new GithubSource("https://github.com/caesay/SquirrelCustomLauncherTestApp", null, false);
var um = new UpdateManager(source, logger, locator); var um = new UpdateManager(source, null, logger, locator);
var info = um.CheckForUpdates(); var info = um.CheckForUpdates();
Assert.NotNull(info); Assert.NotNull(info);
Assert.True(new SemanticVersion(1, 0, 1) == info.TargetFullRelease.Version); Assert.True(new SemanticVersion(1, 0, 1) == info.TargetFullRelease.Version);
@@ -124,8 +124,8 @@ namespace Velopack.Tests
using var logger = _output.BuildLoggerFor<UpdateManagerTests>(); using var logger = _output.BuildLoggerFor<UpdateManagerTests>();
using var _1 = Utility.GetTempDirectory(out var tempPath); using var _1 = Utility.GetTempDirectory(out var tempPath);
var locator = new TestVelopackLocator("MyCoolApp", "1.0.0", tempPath, logger); var locator = new TestVelopackLocator("MyCoolApp", "1.0.0", tempPath, logger);
var source = new GithubSource("https://github.com/caesay/SquirrelCustomLauncherTestApp", null, false, "hello"); var source = new GithubSource("https://github.com/caesay/SquirrelCustomLauncherTestApp", null, false);
var um = new UpdateManager(source, logger, locator); var um = new UpdateManager(source, "hello", logger, locator);
Assert.Throws<ArgumentException>(() => um.CheckForUpdates()); Assert.Throws<ArgumentException>(() => um.CheckForUpdates());
} }
@@ -179,9 +179,9 @@ namespace Velopack.Tests
using var logger = _output.BuildLoggerFor<UpdateManagerTests>(); using var logger = _output.BuildLoggerFor<UpdateManagerTests>();
using var _1 = Utility.GetTempDirectory(out var packagesDir); using var _1 = Utility.GetTempDirectory(out var packagesDir);
var repo = new FakeFixtureRepository(id, false); var repo = new FakeFixtureRepository(id, false);
var source = new SimpleWebSource("http://any.com", null, repo, logger); var source = new SimpleWebSource("http://any.com", repo);
var locator = new TestVelopackLocator(id, "1.0.0", packagesDir, logger); var locator = new TestVelopackLocator(id, "1.0.0", packagesDir, logger);
var um = new UpdateManager(source, logger, locator); var um = new UpdateManager(source, null, logger, locator);
var info = um.CheckForUpdates(); var info = um.CheckForUpdates();
Assert.NotNull(info); Assert.NotNull(info);
@@ -204,17 +204,17 @@ namespace Velopack.Tests
using var logger = _output.BuildLoggerFor<UpdateManagerTests>(); using var logger = _output.BuildLoggerFor<UpdateManagerTests>();
using var _1 = Utility.GetTempDirectory(out var packagesDir); using var _1 = Utility.GetTempDirectory(out var packagesDir);
var repo = new FakeFixtureRepository(id, true); var repo = new FakeFixtureRepository(id, true);
var source = new SimpleWebSource("http://any.com", null, repo, logger); var source = new SimpleWebSource("http://any.com", repo);
var basePkg = (await source.GetReleaseFeed()).Single(x => x.Version == SemanticVersion.Parse(fromVersion)); var basePkg = (await source.GetReleaseFeed(logger)).Single(x => x.Version == SemanticVersion.Parse(fromVersion));
var basePkgFixturePath = PathHelper.GetFixture(basePkg.OriginalFilename); var basePkgFixturePath = PathHelper.GetFixture(basePkg.OriginalFilename);
var basePkgPath = Path.Combine(packagesDir, basePkg.OriginalFilename); var basePkgPath = Path.Combine(packagesDir, basePkg.OriginalFilename);
File.Copy(basePkgFixturePath, basePkgPath); File.Copy(basePkgFixturePath, basePkgPath);
var updateExe = PathHelper.CopyUpdateTo(packagesDir); var updateExe = PathHelper.CopyUpdateTo(packagesDir);
var locator = new TestVelopackLocator(id, fromVersion, var locator = new TestVelopackLocator(id, fromVersion,
packagesDir, null, null, updateExe, logger); packagesDir, null, null, updateExe, null, logger);
var um = new UpdateManager(source, logger, locator); var um = new UpdateManager(source, null, logger, locator);
var info = await um.CheckForUpdatesAsync(); var info = await um.CheckForUpdatesAsync();
Assert.NotNull(info); Assert.NotNull(info);