Skip to content

Commit

Permalink
Merge pull request #3267 from TheCakeIsNaOH/gh1485-install-source-dis…
Browse files Browse the repository at this point in the history
…play

(#1485) Display package source during install/upgrade
  • Loading branch information
gep13 authored Apr 24, 2024
2 parents 03126a9 + 726c01e commit c632298
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/chocolatey.tests.integration/scenarios/InstallScenarios.cs
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,26 @@ public void Should_have_a_version_of_one_dot_zero_dot_zero()
_packageResult.Version.Should().Be(TestVersion());
}

[Fact]
public void Should_contain_message_with_source()
{
var message = "Downloading package from source '{0}'".FormatWith(Configuration.Sources);

MockLogger.Messages.Should().ContainKey(LogLevel.Info.ToString()).WhoseValue.Should()
.Contain(message);
}

[Fact]
public void Should_contain_message_with_download_uri()
{
var packagePath = "file:///{0}/{1}.{2}{3}".FormatWith(Configuration.Sources.Replace("\\","/"), Configuration.PackageNames,
TestVersion(), NuGetConstants.PackageExtension);
var message = "Package download location '{0}'".FormatWith(packagePath);

MockLogger.Messages.Should().ContainKey(LogLevel.Debug.ToString()).WhoseValue.Should()
.Contain(message);
}

[Fact]
[WindowsOnly]
[Platform(Exclude = "Mono")]
Expand Down
20 changes: 20 additions & 0 deletions src/chocolatey.tests.integration/scenarios/UpgradeScenarios.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,26 @@ public void Should_match_the_upgrade_version_of_one_dot_one_dot_zero()
_packageResult.Version.Should().Be("1.1.0");
}

[Fact]
public void Should_contain_message_with_source()
{
var message = "Downloading package from source '{0}'".FormatWith(Configuration.Sources);

MockLogger.Messages.Should().ContainKey(LogLevel.Info.ToString()).WhoseValue.Should()
.Contain(message);
}

[Fact]
public void Should_contain_message_with_download_uri()
{
var packagePath = "file:///{0}/{1}.{2}{3}".FormatWith(Configuration.Sources.Replace("\\", "/"), Configuration.PackageNames,
"1.1.0", NuGetConstants.PackageExtension);
var message = "Package download location '{0}'".FormatWith(packagePath);

MockLogger.Messages.Should().ContainKey(LogLevel.Debug.ToString()).WhoseValue.Should()
.Contain(message);
}

[Fact]
[WindowsOnly]
[Platform(Exclude = "Mono")]
Expand Down
6 changes: 6 additions & 0 deletions src/chocolatey/infrastructure.app/services/NugetService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,9 @@ Version was specified as '{0}'. It is possible that version

_fileSystem.DeleteFile(pathResolver.GetInstalledPackageFilePath(packageDependencyInfo));

this.Log().Info("Downloading package from source '{0}'".FormatWith(packageDependencyInfo.Source));
this.Log().Debug("Package download location '{0}'".FormatWith(packageDependencyInfo.DownloadUri));

ChocolateyProgressInfo.ShouldDisplayDownloadProgress = config.Features.ShowDownloadProgress;

using (var downloadResult = downloadResource.GetDownloadResourceResultAsync(
Expand Down Expand Up @@ -1560,6 +1563,9 @@ public virtual ConcurrentDictionary<string, PackageResult> Upgrade(ChocolateyCon

_fileSystem.DeleteFile(pathResolver.GetInstalledPackageFilePath(packageDependencyInfo));

this.Log().Info("Downloading package from source '{0}'".FormatWith(packageDependencyInfo.Source));
this.Log().Debug("Package download location '{0}'".FormatWith(packageDependencyInfo.DownloadUri));

ChocolateyProgressInfo.ShouldDisplayDownloadProgress = config.Features.ShowDownloadProgress;

using (var downloadResult = downloadResource.GetDownloadResourceResultAsync(
Expand Down

0 comments on commit c632298

Please sign in to comment.