Skip to content

Commit 3df00b6

Browse files
committed
Bug fix and test update
1 parent 7ea4451 commit 3df00b6

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/code/FindHelper.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1221,9 +1221,10 @@ private void FindDependencyPackageVersion(Dependency dep, ServerApiCall currentS
12211221
depPkg = FindDependencyWithLowerBound(dep, currentServer, currentResponseUtil, currentPkg, repository, errors);
12221222
}
12231223
}
1224-
else if (dep.VersionRange.MinVersion.Equals(dep.VersionRange.MaxVersion))
1224+
else if (dep.VersionRange.HasLowerBound && dep.VersionRange.MinVersion.Equals(dep.VersionRange.MaxVersion))
12251225
{
12261226
// Case 2: Exact package version, eg: "1.0.0" or "[1.0.0, 1.0.0]"
1227+
// Note: need to check if VersionRange has lower bound because if it does not, MinVersion will be null
12271228
// Check if the latest version is cached, and if this latest version is the version we're looking for
12281229
if (_knownLatestPkgVersion.TryGetValue(dep.Name, out PSResourceInfo cachedRangePkg) &&
12291230
NuGetVersion.TryParse(cachedRangePkg.Version?.ToString(), out NuGetVersion cachedPkgVersion) &&

test/FindPSResourceTests/FindPSResourceADOV2Server.Tests.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ Describe 'Test HTTP Find-PSResource for ADO V2 Server Protocol' -tags 'CI' {
190190
$res = Find-PSResource -Name $testModuleName -Tag $requiredTag -Repository $ADOV2RepoName -ErrorVariable err -ErrorAction SilentlyContinue
191191
$res | Should -BeNullOrEmpty
192192
$err.Count | Should -BeGreaterThan 0
193-
$err[0].FullyQualifiedErrorId | Should -BeExactly "PackageNotFound,Microsoft.PowerShell.PSResourceGet.Cmdlets.FindPSResource"
193+
$err[0].FullyQualifiedErrorId | Should -BeExactly "GetCountFromResponseFailure,Microsoft.PowerShell.PSResourceGet.Cmdlets.FindPSResource"
194194
}
195195

196196
It "Find resource that satisfies given Name and Tag property (multiple tags)" {
@@ -208,7 +208,7 @@ Describe 'Test HTTP Find-PSResource for ADO V2 Server Protocol' -tags 'CI' {
208208
$res = Find-PSResource -Name $testModuleName -Tag $requiredTags -Repository $ADOV2RepoName -ErrorVariable err -ErrorAction SilentlyContinue
209209
$res | Should -BeNullOrEmpty
210210
$err.Count | Should -BeGreaterThan 0
211-
$err[0].FullyQualifiedErrorId | Should -BeExactly "PackageNotFound,Microsoft.PowerShell.PSResourceGet.Cmdlets.FindPSResource"
211+
$err[0].FullyQualifiedErrorId | Should -BeExactly "GetCountFromResponseFailure,Microsoft.PowerShell.PSResourceGet.Cmdlets.FindPSResource"
212212
}
213213

214214
It "Find all resources that satisfy Name pattern and have specified Tag (single tag)" {
@@ -244,7 +244,7 @@ Describe 'Test HTTP Find-PSResource for ADO V2 Server Protocol' -tags 'CI' {
244244
$res = Find-PSResource -Name $testModuleName -Version "5.0.0" -Tag $requiredTag -Repository $ADOV2RepoName -ErrorVariable err -ErrorAction SilentlyContinue
245245
$res | Should -BeNullOrEmpty
246246
$err.Count | Should -BeGreaterThan 0
247-
$err[0].FullyQualifiedErrorId | Should -BeExactly "PackageNotFound,Microsoft.PowerShell.PSResourceGet.Cmdlets.FindPSResource"
247+
$err[0].FullyQualifiedErrorId | Should -BeExactly "GetCountFromResponseFailure,Microsoft.PowerShell.PSResourceGet.Cmdlets.FindPSResource"
248248
}
249249

250250
It "Find resource that satisfies given Name, Version and Tag property (multiple tags)" {
@@ -264,6 +264,6 @@ Describe 'Test HTTP Find-PSResource for ADO V2 Server Protocol' -tags 'CI' {
264264
$res = Find-PSResource -Name $testModuleName -Version "5.0.0" -Tag $requiredTags -Repository $ADOV2RepoName -ErrorVariable err -ErrorAction SilentlyContinue
265265
$res | Should -BeNullOrEmpty
266266
$err.Count | Should -BeGreaterThan 0
267-
$err[0].FullyQualifiedErrorId | Should -BeExactly "PackageNotFound,Microsoft.PowerShell.PSResourceGet.Cmdlets.FindPSResource"
267+
$err[0].FullyQualifiedErrorId | Should -BeExactly "GetCountFromResponseFailure,Microsoft.PowerShell.PSResourceGet.Cmdlets.FindPSResource"
268268
}
269269
}

0 commit comments

Comments
 (0)