Skip to content

Commit

Permalink
Merge pull request #3060 from AdmiringWorm/fix-broken-tests
Browse files Browse the repository at this point in the history
(#508) Fix broken tests and tests marked as broken
  • Loading branch information
gep13 authored Mar 10, 2023
2 parents b2648fe + b60be7f commit b6a7753
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,7 @@ public void config_should_match_package_result_name()
packageResult.Name.ShouldEqual(Configuration.Input);
}

[Fact, Pending("Current version of the NuGet client library changes this to 1.0"), Broken]
[Fact]
public void should_have_a_version_of_one_dot_zero_dot_zero()
{
packageResult.Version.ShouldEqual("1.0.0");
Expand Down
5 changes: 4 additions & 1 deletion src/chocolatey/infrastructure.app/nuget/NugetList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,14 @@ public static IPackageSearchMetadata find_package(
{
if (version is null)
{
// We only need to force a lower case package name when we
// are using our own repository optimization queries.
var packageNameLower = packageName.to_lower();
var metadataList = new HashSet<IPackageSearchMetadata>();

foreach (var listResource in listResources)
{
var package = listResource.PackageAsync(packageName, config.Prerelease, nugetLogger, CancellationToken.None).GetAwaiter().GetResult();
var package = listResource.PackageAsync(packageNameLower, config.Prerelease, nugetLogger, CancellationToken.None).GetAwaiter().GetResult();
if (package != null)
{
metadataList.Add(package);
Expand Down
2 changes: 1 addition & 1 deletion tests/chocolatey-tests/chocolatey.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ Describe "Ensuring Chocolatey is correctly installed" -Tag Environment, Chocolat
}

# This is skipped when not run in CI because it modifies the local system.
Context 'License warning is worded properly' -Tag FossOnly, Broken -Skip:((-not $env:TEST_KITCHEN) -or (-not (Test-ChocolateyVersionEqualOrHigherThan '1.0.0'))) {
Context 'License warning is worded properly' -Tag FossOnly -Skip:((-not $env:TEST_KITCHEN) -or (-not (Test-ChocolateyVersionEqualOrHigherThan '1.0.0'))) {
BeforeAll {
$null = Invoke-Choco install chocolatey-license-business -y
$Output = Invoke-Choco list -lo
Expand Down
108 changes: 106 additions & 2 deletions tests/chocolatey-tests/commands/choco-install.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1385,8 +1385,8 @@ To install a local, or remote file, you may use:
}

It "should identify a circular dependency" {
$result1.Lines | Should -Contain "Circular dependency detected 'circulardependency1 0.0.1 => circulardependency2 0.0.1 => circulardependency1 0.0.1'."
$result2.Lines | Should -Contain "Circular dependency detected 'circulardependency1 0.0.1 => circulardependency2 0.0.1 => circulardependency1 0.0.1'."
$result1.Lines | Should -Contain "Unable to resolve dependency 'circulardependency1': Circular dependency detected 'circulardependency1 0.0.1 => circulardependency2 0.0.1 => circulardependency1 0.0.1'." -Because $result1.String
$result2.Lines | Should -Contain "Unable to resolve dependency 'circulardependency1': Circular dependency detected 'circulardependency1 0.0.1 => circulardependency2 0.0.1 => circulardependency1 0.0.1'." -Because $result2.String
}
}

Expand Down Expand Up @@ -1570,6 +1570,110 @@ To install a local, or remote file, you may use:
}
}

Context 'Installing a package while passing in an uppercase letter as the identifier' {
BeforeAll {
Restore-ChocolateyInstallSnapshot

$Output = Invoke-Choco install IsDependency --confirm
}

It 'Exits with Success (0)' {
$Output.ExitCode | Should -Be 0
}

It 'Installs package to expected directory' {
"$env:ChocolateyInstall\lib\isdependency\isdependency.nuspec" | Should -Exist
}

It 'Outputs installation was successful' {
$Output.Lines | Should -Contain 'The install of isdependency was successful.' -Because $Output.String
}

It "Installs the expected version of the package" {
"$env:ChocolateyInstall\lib\isdependency\isdependency.nuspec" | Should -Exist
[xml]$XML = Get-Content "$env:ChocolateyInstall\lib\isdependency\isdependency.nuspec"
$XML.package.metadata.version | Should -Be "2.1.0"
}
}

Context 'Installing a package while passing in an uppercase letter as the identifier (Repository optimization disabled)' {
BeforeAll {
Restore-ChocolateyInstallSnapshot

$Output = Invoke-Choco install IsDependency --confirm --disable-repository-optimizations
}

It 'Exits with Success (0)' {
$Output.ExitCode | Should -Be 0
}

It 'Installs package to expected directory' {
"$env:ChocolateyInstall\lib\isdependency\isdependency.nuspec" | Should -Exist
}

It 'Outputs installation was successful' {
$Output.Lines | Should -Contain 'The install of isdependency was successful.' -Because $Output.String
}

It "Installs the expected version of the package" {
"$env:ChocolateyInstall\lib\isdependency\isdependency.nuspec" | Should -Exist
[xml]$XML = Get-Content "$env:ChocolateyInstall\lib\isdependency\isdependency.nuspec"
$XML.package.metadata.version | Should -Be "2.1.0"
}
}

Context 'Installing a package while passing in an uppercase letter as the identifier and specific version' {
BeforeAll {
Restore-ChocolateyInstallSnapshot

$Output = Invoke-Choco install IsDependency --confirm --disable-repository-optimizations --version 1.0.0
}

It 'Exits with Success (0)' {
$Output.ExitCode | Should -Be 0
}

It 'Installs package to expected directory' {
"$env:ChocolateyInstall\lib\isdependency\isdependency.nuspec" | Should -Exist
}

It 'Outputs installation was successful' {
$Output.Lines | Should -Contain 'The install of isdependency was successful.' -Because $Output.String
}

It "Installs the expected version of the package" {
"$env:ChocolateyInstall\lib\isdependency\isdependency.nuspec" | Should -Exist
[xml]$XML = Get-Content "$env:ChocolateyInstall\lib\isdependency\isdependency.nuspec"
$XML.package.metadata.version | Should -Be "1.0.0"
}
}

Context 'Installing a package while passing in an uppercase letter as the identifier and specific version (Repository optimization disabled)' {
BeforeAll {
Restore-ChocolateyInstallSnapshot

$Output = Invoke-Choco install IsDependency --confirm --disable-repository-optimizations --version 1.0.0
}

It 'Exits with Success (0)' {
$Output.ExitCode | Should -Be 0
}

It 'Installs package to expected directory' {
"$env:ChocolateyInstall\lib\isdependency\isdependency.nuspec" | Should -Exist
}

It 'Outputs installation was successful' {
$Output.Lines | Should -Contain 'The install of isdependency was successful.' -Because $Output.String
}

It "Installs the expected version of the package" {
"$env:ChocolateyInstall\lib\isdependency\isdependency.nuspec" | Should -Exist
[xml]$XML = Get-Content "$env:ChocolateyInstall\lib\isdependency\isdependency.nuspec"
$XML.package.metadata.version | Should -Be "1.0.0"
}
}

# This needs to be the last test in this block, to ensure NuGet configurations aren't being created.
# Any tests after this block are expected to generate the configuration as they're explicitly using the NuGet CLI
Test-NuGetPaths
Expand Down
4 changes: 1 addition & 3 deletions tests/chocolatey-tests/commands/choco-list.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,7 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, ListCommand, SearchComma
}
}

# TODO: Using All versions and pre release together is currently broken
# in vNext of Chocolatey CLI.
Context "Searching all available packages (allowing prerelease)" -Tag Broken {
Context "Searching all available packages (allowing prerelease)" -Tag Testing {
BeforeAll {
$Output = Invoke-Choco $_ --AllVersions --PreRelease
}
Expand Down

0 comments on commit b6a7753

Please sign in to comment.