mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
Sort out OSX tests
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Velopack.Sources;
|
||||
|
||||
namespace Velopack.Tests.TestHelpers
|
||||
{
|
||||
@@ -10,9 +11,11 @@ namespace Velopack.Tests.TestHelpers
|
||||
{
|
||||
private readonly string _pkgId;
|
||||
private readonly IEnumerable<ReleaseEntry> _releases;
|
||||
private readonly string _releasesName;
|
||||
|
||||
public FakeFixtureRepository(string pkgId, bool mockLatestFullVer)
|
||||
public FakeFixtureRepository(string pkgId, bool mockLatestFullVer, string channel = null)
|
||||
{
|
||||
_releasesName = SourceBase.GetReleasesFileNameImpl(channel);
|
||||
_pkgId = pkgId;
|
||||
var releases = ReleaseEntry.BuildReleasesFile(PathHelper.GetFixturesDir(), false)
|
||||
.Where(r => r.OriginalFilename.StartsWith(_pkgId))
|
||||
@@ -35,13 +38,16 @@ namespace Velopack.Tests.TestHelpers
|
||||
|
||||
public Task<byte[]> DownloadBytes(string url, string authorization = null, string accept = null)
|
||||
{
|
||||
if (url.Contains("/RELEASES?")) {
|
||||
if (url.Contains($"/{_releasesName}?")) {
|
||||
MemoryStream ms = new MemoryStream();
|
||||
ReleaseEntry.WriteReleaseFile(_releases, ms);
|
||||
return Task.FromResult(ms.ToArray());
|
||||
}
|
||||
|
||||
var rel = _releases.FirstOrDefault(r => url.EndsWith(r.OriginalFilename));
|
||||
if (rel == null)
|
||||
throw new Exception("Fake release not found: " + url);
|
||||
|
||||
var filePath = PathHelper.GetFixture(rel.OriginalFilename);
|
||||
if (!File.Exists(filePath)) {
|
||||
throw new NotSupportedException("FakeFixtureRepository doesn't have: " + rel.OriginalFilename);
|
||||
|
||||
@@ -26,7 +26,10 @@ namespace Velopack.Tests
|
||||
{
|
||||
using var logger = _output.BuildLoggerFor<UpdateManagerTests>();
|
||||
using var _1 = Utility.GetTempDirectory(out var tempPath);
|
||||
File.WriteAllText(Path.Combine(tempPath, "RELEASES"), """
|
||||
|
||||
string releasesSuffix = VelopackRuntimeInfo.IsOSX ? "-osx" : "";
|
||||
|
||||
File.WriteAllText(Path.Combine(tempPath, "RELEASES" + releasesSuffix), """
|
||||
3a2eadd15dd984e4559f2b4d790ec8badaeb6a39 MyCoolApp-1.1.0.nupkg 1040561
|
||||
94689fede03fed7ab59c24337673a27837f0c3ec MyCoolApp-1.0.0.nupkg 1004502
|
||||
""");
|
||||
@@ -43,12 +46,12 @@ namespace Velopack.Tests
|
||||
{
|
||||
using var logger = _output.BuildLoggerFor<UpdateManagerTests>();
|
||||
using var _1 = Utility.GetTempDirectory(out var tempPath);
|
||||
File.WriteAllText(Path.Combine(tempPath, "RELEASES-osx-x64"), """
|
||||
File.WriteAllText(Path.Combine(tempPath, "RELEASES-experimental"), """
|
||||
3a2eadd15dd984e4559f2b4d790ec8badaeb6a39 MyCoolApp-1.1.0.nupkg 1040561
|
||||
94689fede03fed7ab59c24337673a27837f0c3ec MyCoolApp-1.0.0.nupkg 1004502
|
||||
""");
|
||||
var locator = new TestVelopackLocator("MyCoolApp", "1.0.0", tempPath, logger);
|
||||
var um = new UpdateManager(tempPath, "osx-x64", logger, locator);
|
||||
var um = new UpdateManager(tempPath, "experimental", logger, locator);
|
||||
var info = um.CheckForUpdates();
|
||||
Assert.NotNull(info);
|
||||
Assert.True(new SemanticVersion(1, 1, 0) == info.TargetFullRelease.Version);
|
||||
@@ -79,7 +82,8 @@ namespace Velopack.Tests
|
||||
{
|
||||
using var logger = _output.BuildLoggerFor<UpdateManagerTests>();
|
||||
using var _1 = Utility.GetTempDirectory(out var tempPath);
|
||||
File.WriteAllText(Path.Combine(tempPath, "RELEASES"), """
|
||||
string releasesSuffix = VelopackRuntimeInfo.IsOSX ? "-osx" : "";
|
||||
File.WriteAllText(Path.Combine(tempPath, "RELEASES" + releasesSuffix), """
|
||||
3a2eadd15dd984e4559f2b4d790ec8badaeb6a39 MyCoolApp-1.1.0.nupkg 1040561
|
||||
3a2eadd15dd984e4559f2b4d790ec8badaeb6a39 MyCoolApp-1.2.0.nupkg 1040561
|
||||
14db31d2647c6d2284882a2e101924a9c409ee67 MyCoolApp-1.2.0-delta.nupkg 80396
|
||||
@@ -126,7 +130,8 @@ namespace Velopack.Tests
|
||||
{
|
||||
using var logger = _output.BuildLoggerFor<UpdateManagerTests>();
|
||||
using var _1 = Utility.GetTempDirectory(out var tempPath);
|
||||
File.WriteAllText(Path.Combine(tempPath, "RELEASES"), """
|
||||
string releasesSuffix = VelopackRuntimeInfo.IsOSX ? "-osx" : "";
|
||||
File.WriteAllText(Path.Combine(tempPath, "RELEASES" + releasesSuffix), """
|
||||
3a2eadd15dd984e4559f2b4d790ec8badaeb6a39 MyCoolApp-1.1.0.nupkg 1040561
|
||||
94689fede03fed7ab59c24337673a27837f0c3ec MyCoolApp-1.0.0.nupkg 1004502
|
||||
""");
|
||||
@@ -141,7 +146,8 @@ namespace Velopack.Tests
|
||||
{
|
||||
using var logger = _output.BuildLoggerFor<UpdateManagerTests>();
|
||||
using var _1 = Utility.GetTempDirectory(out var tempPath);
|
||||
File.WriteAllText(Path.Combine(tempPath, "RELEASES"), """
|
||||
string releasesSuffix = VelopackRuntimeInfo.IsOSX ? "-osx" : "";
|
||||
File.WriteAllText(Path.Combine(tempPath, "RELEASES" + releasesSuffix), """
|
||||
3a2eadd15dd984e4559f2b4d790ec8badaeb6a39 MyCoolApp-1.1.0.nupkg 1040561
|
||||
94689fede03fed7ab59c24337673a27837f0c3ec MyCoolApp-1.0.0.nupkg 1004502
|
||||
""");
|
||||
|
||||
Reference in New Issue
Block a user