public void CanParseGeneratedReleaseEntryAsString() { var path = IntegrationTestHelper.GetPath("fixtures", "Shimmer.Core.1.1.0.0.nupkg"); var entryAsString = ReleaseEntry.GenerateFromFile(path).EntryAsString; ReleaseEntry.ParseReleaseEntry(entryAsString); }
private void VerifyPatchedFile(string relativeFilePath, string inputFile, string tempTargetFile) { var shaFile = Regex.Replace(inputFile, @"\.(bs)?diff$", ".shasum"); var expectedReleaseEntry = ReleaseEntry.ParseReleaseEntry(File.ReadAllText(shaFile, Encoding.UTF8)); var actualReleaseEntry = ReleaseEntry.GenerateFromFile(tempTargetFile); if (expectedReleaseEntry.Filesize != actualReleaseEntry.Filesize) { Log.WarnFormat( "Patched file {0} has incorrect size, expected {1}, got {2}", relativeFilePath, expectedReleaseEntry.Filesize, actualReleaseEntry.Filesize); throw new ChecksumFailedException { Filename = relativeFilePath }; } if (expectedReleaseEntry.SHA1 != actualReleaseEntry.SHA1) { Log.WarnFormat( "Patched file {0} has incorrect SHA1, expected {1}, got {2}", relativeFilePath, expectedReleaseEntry.SHA1, actualReleaseEntry.SHA1); throw new ChecksumFailedException { Filename = relativeFilePath }; } }
public void WhenReleasesAreOutOfOrderSortByVersion() { var path = Path.GetTempFileName(); var firstVersion = new Version("1.0.0"); var secondVersion = new Version("1.1.0"); var thirdVersion = new Version("1.2.0"); var releaseEntries = new[] { ReleaseEntry.ParseReleaseEntry(MockReleaseEntry("Espera-1.2.0-delta.nupkg")), ReleaseEntry.ParseReleaseEntry(MockReleaseEntry("Espera-1.1.0-delta.nupkg")), ReleaseEntry.ParseReleaseEntry(MockReleaseEntry("Espera-1.1.0-full.nupkg")), ReleaseEntry.ParseReleaseEntry(MockReleaseEntry("Espera-1.2.0-full.nupkg")), ReleaseEntry.ParseReleaseEntry(MockReleaseEntry("Espera-1.0.0-full.nupkg")) }; ReleaseEntry.WriteReleaseFile(releaseEntries, path); var releases = ReleaseEntry.ParseReleaseFile(File.ReadAllText(path)).ToArray(); Assert.Equal(firstVersion, releases[0].Version); Assert.Equal(secondVersion, releases[1].Version); Assert.Equal(true, releases[1].IsDelta); Assert.Equal(secondVersion, releases[2].Version); Assert.Equal(false, releases[2].IsDelta); Assert.Equal(thirdVersion, releases[3].Version); Assert.Equal(true, releases[3].IsDelta); Assert.Equal(thirdVersion, releases[4].Version); Assert.Equal(false, releases[4].IsDelta); }
public void ParseValidReleaseEntryLines(string releaseEntry, string fileName, long fileSize) { var fixture = ReleaseEntry.ParseReleaseEntry(releaseEntry); Assert.Equal(fileName, fixture.Filename); Assert.Equal(fileSize, fixture.Filesize); }
public void WhenPreReleasesAreOutOfOrderSortByNumericSuffix() { var path = Path.GetTempFileName(); var firstVersion = new SemanticVersion("1.1.9-beta105"); var secondVersion = new SemanticVersion("1.2.0-beta9"); var thirdVersion = new SemanticVersion("1.2.0-beta10"); var fourthVersion = new SemanticVersion("1.2.0-beta100"); var releaseEntries = new[] { ReleaseEntry.ParseReleaseEntry(MockReleaseEntry("Espera-1.2.0-beta1-full.nupkg")), ReleaseEntry.ParseReleaseEntry(MockReleaseEntry("Espera-1.2.0-beta9-full.nupkg")), ReleaseEntry.ParseReleaseEntry(MockReleaseEntry("Espera-1.2.0-beta100-full.nupkg")), ReleaseEntry.ParseReleaseEntry(MockReleaseEntry("Espera-1.1.9-beta105-full.nupkg")), ReleaseEntry.ParseReleaseEntry(MockReleaseEntry("Espera-1.2.0-beta10-full.nupkg")) }; ReleaseEntry.WriteReleaseFile(releaseEntries, path); var releases = ReleaseEntry.ParseReleaseFile(File.ReadAllText(path)).ToArray(); Assert.Equal(firstVersion, releases[0].Version); Assert.Equal(secondVersion, releases[2].Version); Assert.Equal(thirdVersion, releases[3].Version); Assert.Equal(fourthVersion, releases[4].Version); }
public void ParseVersionTest(string releaseEntry, int major, int minor, int patch, int revision, string prerelease, bool isDelta) { var fixture = ReleaseEntry.ParseReleaseEntry(releaseEntry); Assert.Equal(new SemanticVersion(new Version(major, minor, patch, revision), prerelease), fixture.Version); Assert.Equal(isDelta, fixture.IsDelta); }
public void ParseVersionTest(string releaseEntry, int expectedMajor, int expectedMinor) { var fixture = ReleaseEntry.ParseReleaseEntry(releaseEntry); Assert.Equal(expectedMajor, fixture.Version.Major); Assert.Equal(expectedMinor, fixture.Version.Minor); }
public Task <UpdateInfo> CheckForUpdate(bool ignoreDeltaUpdates = false, Action <int> progress = null) { var releaseEntry = ReleaseEntry.ParseReleaseEntry(DummyReleaseEntry); var updateInfo = UpdateInfo.Create(releaseEntry, new[] { releaseEntry }, "dummy"); return(Task.FromResult(updateInfo)); }
public void WhenCurrentReleaseMatchesLastReleaseReturnNull() { var package = new ReleasePackage("Espera-1.7.6-beta.nupkg"); var releaseEntries = new[] { ReleaseEntry.ParseReleaseEntry(MockReleaseEntry("Espera-1.7.6-beta.nupkg")) }; Assert.Null(ReleaseEntry.GetPreviousRelease( releaseEntries, package, @"C:\temp\somefolder")); }
public void ParseStagingPercentageTest(string releaseEntry, int major, int minor, int patch, int revision, string prerelease, bool isDelta, float?stagingPercentage) { var fixture = ReleaseEntry.ParseReleaseEntry(releaseEntry); Assert.Equal(new SemanticVersion(new Version(major, minor, patch, revision), prerelease), fixture.Version); Assert.Equal(isDelta, fixture.IsDelta); if (stagingPercentage.HasValue) { Assert.True(Math.Abs(fixture.StagingPercentage.Value - stagingPercentage.Value) < 0.001); } else { Assert.Null(fixture.StagingPercentage); } }
public void LuckyUsersGetBetaSoftware(string inputGuid) { var path = Path.GetTempFileName(); var ourGuid = Guid.ParseExact(inputGuid, "B"); var releaseEntries = new[] { ReleaseEntry.ParseReleaseEntry(MockReleaseEntry("Espera-1.2.0-full.nupkg", 0.25f)), ReleaseEntry.ParseReleaseEntry(MockReleaseEntry("Espera-1.1.0-full.nupkg")), ReleaseEntry.ParseReleaseEntry(MockReleaseEntry("Espera-1.0.0-full.nupkg")) }; ReleaseEntry.WriteReleaseFile(releaseEntries, path); var releases = ReleaseEntry.ParseReleaseFileAndApplyStaging(File.ReadAllText(path), ourGuid).ToArray(); Assert.Equal(3, releases.Length); }
public void BorkedUsersGetProductionSoftware() { var path = Path.GetTempFileName(); var ourGuid = default(Guid?); var releaseEntries = new[] { ReleaseEntry.ParseReleaseEntry(MockReleaseEntry("Espera-1.2.0-full.nupkg", 0.1f)), ReleaseEntry.ParseReleaseEntry(MockReleaseEntry("Espera-1.1.0-full.nupkg")), ReleaseEntry.ParseReleaseEntry(MockReleaseEntry("Espera-1.0.0-full.nupkg")) }; ReleaseEntry.WriteReleaseFile(releaseEntries, path); var releases = ReleaseEntry.ParseReleaseFileAndApplyStaging(File.ReadAllText(path), ourGuid).ToArray(); Assert.Equal(2, releases.Length); }
public void WhenMultipleReleaseMatchesReturnEarlierResult() { var expected = new Version("1.7.5"); var package = new ReleasePackage("Espera-1.7.6-beta.nupkg"); var releaseEntries = new[] { ReleaseEntry.ParseReleaseEntry(MockReleaseEntry("Espera-1.7.6-beta.nupkg")), ReleaseEntry.ParseReleaseEntry(MockReleaseEntry("Espera-1.7.5-beta.nupkg")) }; var actual = ReleaseEntry.GetPreviousRelease( releaseEntries, package, @"C:\temp\"); Assert.Equal(expected, actual.Version); }
public void WhenMultipleReleasesFoundInOtherOrderReturnPreviousVersion() { var expected = new Version("1.7.6"); var input = new ReleasePackage("Espera-1.7.7-beta.nupkg"); var releaseEntries = new[] { ReleaseEntry.ParseReleaseEntry(MockReleaseEntry("Espera-1.7.5-beta.nupkg")), ReleaseEntry.ParseReleaseEntry(MockReleaseEntry("Espera-1.7.6-beta.nupkg")) }; var actual = ReleaseEntry.GetPreviousRelease( releaseEntries, input, @"C:\temp\"); Assert.Equal(expected, actual.Version); }
public void StagingUsersGetBetaSoftware() { // NB: We're kind of using a hack here, in that we know that the // last 4 bytes are used as the percentage, and the percentage // effectively measures, "How close are you to zero". Guid.Empty // is v close to zero, because it is zero. var path = Path.GetTempFileName(); var ourGuid = Guid.Empty; var releaseEntries = new[] { ReleaseEntry.ParseReleaseEntry(MockReleaseEntry("Espera-1.2.0-full.nupkg", 0.1f)), ReleaseEntry.ParseReleaseEntry(MockReleaseEntry("Espera-1.1.0-full.nupkg")), ReleaseEntry.ParseReleaseEntry(MockReleaseEntry("Espera-1.0.0-full.nupkg")) }; ReleaseEntry.WriteReleaseFile(releaseEntries, path); var releases = ReleaseEntry.ParseReleaseFileAndApplyStaging(File.ReadAllText(path), ourGuid).ToArray(); Assert.Equal(3, releases.Length); }
public void CheckPackageName(string releaseEntry, string expected) { var fixture = ReleaseEntry.ParseReleaseEntry(releaseEntry); Assert.Equal(expected, fixture.PackageName); }
public void ParseThrowsWhenInvalidReleaseEntryLines(string releaseEntry) { Assert.Throws <Exception>(() => ReleaseEntry.ParseReleaseEntry(releaseEntry)); }
public MainWindowViewModel() { ReleasesListHint = "Type in a release location URL or path to files"; ReleasesList = new ReactiveList <ReleaseEntryViewModel>(); ReleasesList.ChangeTrackingEnabled = true; CheckRemoteUpdateInfo = ReactiveCommand.CreateAsyncTask( this.WhenAny(x => x.ReleaseLocation, x => !String.IsNullOrWhiteSpace(x.Value)), async _ => { ReleasesListHint = ""; var releaseData = default(String); if (Regex.IsMatch(ReleaseLocation, "^https?://", RegexOptions.IgnoreCase)) { var wc = new WebClient(); releaseData = await wc.DownloadStringTaskAsync(ReleaseLocation + "/RELEASES"); } else { releaseData = File.ReadAllText(releaseData, Encoding.UTF8); } var ret = releaseData.Split('\n') .Select(x => ReleaseEntry.ParseReleaseEntry(x)) .ToList(); return(ret); }); CheckRemoteUpdateInfo.ThrownExceptions .Subscribe(ex => ReleasesListHint = "Failed to check for updates: " + ex.Message); CheckRemoteUpdateInfo .Subscribe(x => { var vms = x .Where(y => y.IsDelta == false) .Select(y => new ReleaseEntryViewModel(y)); using (ReleasesList.SuppressChangeNotifications()) { ReleasesList.Clear(); ReleasesList.AddRange(vms); } }); this.WhenAnyValue(x => x.ReleaseLocation) .Throttle(TimeSpan.FromMilliseconds(750), RxApp.MainThreadScheduler) .InvokeCommand(CheckRemoteUpdateInfo); ReleasesList.ItemChanged .Where(x => x.PropertyName == "CurrentAction") .Subscribe(x => updateStartsAndEnds(x.Sender)); DoIt = ReactiveCommand.CreateAsyncTask( this.WhenAny(x => x.ReleasesList.Count, x => x.Value > 0), async _ => { var releasesToApply = ReleasesList.Where(x => x.Enabled).ToList(); if (releasesToApply.Count < 1 || releasesToApply.All(x => x.CurrentAction == ReleaseEntryActions.None)) { await UserError.Throw(new OkUserError("Nothing to do", "At least one release must have the 'Start' action")); return; } var appName = ReleasesList[0].Name; var rootAppDir = Environment.ExpandEnvironmentVariables("%LocalAppData%\\" + appName); if (Directory.Exists(rootAppDir)) { var result = await UserError.Throw(new YesNoUserError( "App already installed", String.Format("App '{0}' is already installed, remove it before running install?", appName))); if (result == RecoveryOptionResult.CancelOperation) { return; } if (result == RecoveryOptionResult.RetryOperation) { using (var mgr = new UpdateManager(null, appName, Environment.ExpandEnvironmentVariables("%LocalAppData%"))) { await mgr.FullUninstall(); } } } foreach (var release in releasesToApply) { release.ReleaseLocation = this.ReleaseLocation; await release.ApplyThisRelease.ExecuteAsync(null); } }); }
public void EntryAsStringMatchesParsedInput(string releaseEntry) { var fixture = ReleaseEntry.ParseReleaseEntry(releaseEntry); Assert.Equal(releaseEntry, fixture.EntryAsString); }