Skip to content

Commit

Permalink
Bugfix: Version can be null.
Browse files Browse the repository at this point in the history
  • Loading branch information
peters committed Jul 15, 2020
1 parent c4eeae3 commit 04a377b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
19 changes: 16 additions & 3 deletions src/Snap.Tests/Core/SnapUpdateManagerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,16 @@ public SnapUpdateManagerTests(BaseFixture baseFixture, BaseFixturePackaging base
_snapCryptoProvider, _snapEmbeddedResources, _snapPack);
}

[Fact]
public async Task TestGetSnapReleasesAsync_SnapHttpFeed()
[Theory]
[InlineData(false)]
[InlineData(true)]
public async Task TestGetSnapReleasesAsync_SnapHttpFeed(bool versionIsNull)
{
var snapApp = _baseFixturePackaging.BuildSnapApp();
if (versionIsNull)
{
snapApp.Version = null;
}

var snapChannel = snapApp.Channels.First(x => x.UpdateFeed is SnapHttpFeed);
snapApp.SetCurrentChannel(snapChannel.Name);
Expand Down Expand Up @@ -92,7 +98,14 @@ public async Task TestGetSnapReleasesAsync_SnapHttpFeed()
Assert.Collection(headers, pair => Assert.Equal("X-Snapx-App-Id", snapApp.Id));
Assert.Collection(headers, pair => Assert.Equal("X-Snapx-Channel", snapChannel.Name));
Assert.Collection(headers, pair => Assert.Equal("X-Snapx-Application-Id", applicationId));
Assert.Collection(headers, pair => Assert.Equal("X-Snapx-Application-Version", snapApp.Version.ToNormalizedString()));
if (versionIsNull)
{
Assert.Collection(headers, pair => Assert.Null("X-Snapx-Application-Version"));
}
else
{
Assert.Collection(headers, pair => Assert.Equal("X-Snapx-Application-Version", snapApp.Version.ToNormalizedString()));
}
});

var snapUpdateManager = BuildUpdateManager(_baseFixturePackaging.WorkingDirectory, snapApp, _nugetServiceMock.Object,
Expand Down
2 changes: 1 addition & 1 deletion src/Snap/Core/SnapPackageManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public async Task<PackageSource> GetPackageSourceAsync(
{ "X-Snapx-App-Id", snapApp.Id},
{ "X-Snapx-Channel", channel.Name },
{ "X-Snapx-Application-Id", applicationId },
{ "X-Snapx-Application-Version", snapApp.Version.ToNormalizedString() }
{ "X-Snapx-Application-Version", snapApp.Version?.ToNormalizedString() }
};

using var stream = await _snapHttpClient.GetStreamAsync(feed.Source, headers);
Expand Down

0 comments on commit 04a377b

Please sign in to comment.