Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 1 addition & 29 deletions GVFS/GVFS.Common/GitHubUpgrader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -540,37 +540,9 @@ public bool TryLoad(out string error)
this.UpgradeRing = RingType.NoConfig;

string ringConfig = null;
string upgradeFeedUrl = null;
string loadError = "Could not read GVFS Config." + Environment.NewLine + GVFSConstants.UpgradeVerbMessages.SetUpgradeRingCommand;

// There are couple config settings that contain info about Upgrade rings.
// upgrade.ring and upgrade.feedURL. upgrade.feedURL will override upgrade.ring
// config. If upgrade.feedURL is set, but does not contain valid ring info then
// upgrade ring would be set to NoConfig and auto upgrade checks will fail.
if (!this.LocalConfig.TryGetConfig(GVFSConstants.LocalGVFSConfig.UpgradeFeedUrl, out upgradeFeedUrl, out error))
{
error = loadError;
return false;
}

// If upgradeFeedUrl is available then use it for the ring config, if not use regular
// upgrade.ring.
if (!string.IsNullOrEmpty(upgradeFeedUrl))
{
this.UpgradeRing = RingType.None;

string[] expectedRings = new string[] { RingType.Slow.ToString(), RingType.Fast.ToString() };
foreach (string ring in expectedRings)
{
string ringSubstring = $"@{ring}/";
if (upgradeFeedUrl.IndexOf(ringSubstring, StringComparison.OrdinalIgnoreCase) != -1)
{
ringConfig = ring;
break;
}
}
}
else if (!this.LocalConfig.TryGetConfig(GVFSConstants.LocalGVFSConfig.UpgradeRing, out ringConfig, out error))
if (!this.LocalConfig.TryGetConfig(GVFSConstants.LocalGVFSConfig.UpgradeRing, out ringConfig, out error))
{
error = loadError;
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,75 +80,6 @@ public void UpgradeAvailableOnSlowWhileOnLocalFastRing()
expectedUpgradeVersion:UpgradeTests.NewerThanLocalVersion);
}

[TestCase]
public void RingInNugetFeedURLOverridesUpgradeRing()
{
// Pretend there is an upgrade available in Fast ring. Set upgrade.ring
// to fast and verify that Upgrader returns the new version.
Version newVersion;
string error;
this.SetUpgradeRing(GitHubUpgrader.GitHubUpgraderConfig.RingType.Fast.ToString());

// Replace pretend upgrade Release set by UpgradeTests.Setup() method
this.Upgrader.PretendNewReleaseAvailableAtRemote(UpgradeTests.NewerThanLocalVersion, GitHubUpgrader.GitHubUpgraderConfig.RingType.Fast);

this.Upgrader.TryQueryNewestVersion(out newVersion, out error).ShouldBeTrue();
newVersion.ShouldNotBeNull();
newVersion.ToString().ShouldEqual(UpgradeTests.NewerThanLocalVersion);

// Now add upgrade.feedurl with Slow ring info. The Slow ring in upgrade.feedurl should
// override the Fast that is set already (in the steps above) in upgrade.ring. Since
// there is no upgrade available in Slow, Verify that Upgrader returns Null upgrade
// this time.
string feedUrlWithSlowRing = "https://foo.bar.visualstudio.com/helloworld/_packaging/GVFS@Slow/nuget/v3/index.json";
this.LocalConfig.TrySetConfig("upgrade.feedurl", feedUrlWithSlowRing, out error);
this.Upgrader.Config.TryLoad(out error).ShouldBeTrue();

this.Upgrader.TryQueryNewestVersion(out newVersion, out error).ShouldBeTrue();
newVersion.ShouldBeNull();
error.ShouldContain("Great news");
}

[TestCase]
public void FastUpgradeRingAndNoRingInNugetFeedURLReturnsNoUpgrade()
{
// Pretend there is an upgrade available in Fast ring. Set upgrade.ring
// to fast and verify that Upgrader returns the new version.
Version newVersion;
string error;
this.SetUpgradeRing(GitHubUpgrader.GitHubUpgraderConfig.RingType.Fast.ToString());

// Replace pretend upgrade Release set by UpgradeTests.Setup() method
this.Upgrader.PretendNewReleaseAvailableAtRemote(UpgradeTests.NewerThanLocalVersion, GitHubUpgrader.GitHubUpgraderConfig.RingType.Fast);

this.Upgrader.TryQueryNewestVersion(out newVersion, out error).ShouldBeTrue();
newVersion.ShouldNotBeNull();

// Now add upgrade.feedurl with no ring info. The presence of upgrade.feedurl config
// should force upgrader to reset its ring to the one specified in upgrade.feedurl.
// But since there is no ring specified in upgrade.feedurl, upgrader should have no valid
// ring now. Verify that Upgrader returns Null upgrade this time.
string feedUrlWithNoRing = "https://foo.bar.visualstudio.com/helloworld/GVFS/nuget/v3/index.json";
this.LocalConfig.TrySetConfig("upgrade.feedurl", feedUrlWithNoRing, out error);
this.Upgrader.Config.TryLoad(out error).ShouldBeTrue();

this.Upgrader.TryQueryNewestVersion(out newVersion, out error).ShouldBeTrue();
newVersion.ShouldBeNull();
}

[TestCase]
public void NoRingInNugetFeedURLReturnsNullUpgrade()
{
string error;
string feedUrlWithNoRing = "https://foo.bar.visualstudio.com/helloworld/_packaging/GVFS/nuget/v3/index.json";
this.LocalConfig.TrySetConfig("upgrade.feedurl", feedUrlWithNoRing, out error);
this.Upgrader.Config.TryLoad(out error).ShouldBeTrue();

Version newVersion;
this.Upgrader.TryQueryNewestVersion(out newVersion, out error).ShouldBeTrue();
newVersion.ShouldBeNull();
}

public override void NoneLocalRing()
{
throw new NotSupportedException();
Expand Down