Skip to content

Commit 177af24

Browse files
committed
add find and install tests for 2 digit pkg
1 parent 5840fa6 commit 177af24

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

test/FindPSResourceTests/FindPSResourceContainerRegistryServer.Tests.ps1

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Describe 'Test HTTP Find-PSResource for ACR Server Protocol' -tags 'CI' {
88

99
BeforeAll{
1010
$testModuleName = "test-module"
11+
$testModuleWith2DigitVersion = "test-2DigitPkg"
1112
$testModuleParentName = "test_parent_mod"
1213
$testModuleDependencyName = "test_dependency_mod"
1314
$testScriptName = "test-script"
@@ -82,6 +83,25 @@ Describe 'Test HTTP Find-PSResource for ACR Server Protocol' -tags 'CI' {
8283
$res.Count | Should -BeGreaterOrEqual 1
8384
}
8485

86+
It "Find resource when version contains different number of digits than the normalized version" {
87+
# the resource has version "1.0", but querying with any equivalent version should work
88+
$res1DigitVersion = Find-PSResource -Name $testModuleWith2DigitVersion -Version "1" -Repository $ACRRepoName
89+
$res1DigitVersion | Should -Not -BeNullOrEmpty
90+
$res1DigitVersion.Version | Should -Be "1.0"
91+
92+
$res2DigitVersion = Find-PSResource -Name $testModuleWith2DigitVersion -Version "1.0" -Repository $ACRRepoName
93+
$res2DigitVersion | Should -Not -BeNullOrEmpty
94+
$res2DigitVersion.Version | Should -Be "1.0"
95+
96+
$res3DigitVersion = Find-PSResource -Name $testModuleWith2DigitVersion -Version "1.0.0" -Repository $ACRRepoName
97+
$res3DigitVersion | Should -Not -BeNullOrEmpty
98+
$res3DigitVersion.Version | Should -Be "1.0"
99+
100+
$res4DigitVersion = Find-PSResource -Name $testModuleWith2DigitVersion -Version "1.0.0.0" -Repository $ACRRepoName
101+
$res4DigitVersion | Should -Not -BeNullOrEmpty
102+
$res4DigitVersion.Version | Should -Be "1.0"
103+
}
104+
85105
It "Find module and dependencies when -IncludeDependencies is specified" {
86106
$res = Find-PSResource -Name $testModuleParentName -Repository $ACRRepoName -IncludeDependencies
87107
$res | Should -Not -BeNullOrEmpty

test/InstallPSResourceTests/InstallPSResourceContainerRegistryServer.Tests.ps1

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Describe 'Test Install-PSResource for ACR scenarios' -tags 'CI' {
1010
BeforeAll {
1111
$testModuleName = "test-module"
1212
$testModuleName2 = "test-module2"
13+
$testModuleWith2DigitVersion = "test-2DigitPkg"
1314
$testCamelCaseModuleName = "test-camelCaseModule"
1415
$testCamelCaseScriptName = "test-camelCaseScript"
1516
$testModuleParentName = "test_parent_mod"
@@ -33,7 +34,7 @@ Describe 'Test Install-PSResource for ACR scenarios' -tags 'CI' {
3334
}
3435

3536
AfterEach {
36-
Uninstall-PSResource $testModuleName, $testModuleName2, $testCamelCaseModuleName, $testScriptName, $testCamelCaseScriptName -Version "*" -SkipDependencyCheck -ErrorAction SilentlyContinue
37+
Uninstall-PSResource $testModuleName, $testModuleName2, $testCamelCaseModuleName, $testScriptName, $testCamelCaseScriptName, $testModuleWith2DigitVersion -Version "*" -SkipDependencyCheck -ErrorAction SilentlyContinue
3738
}
3839

3940
AfterAll {
@@ -75,6 +76,38 @@ Describe 'Test Install-PSResource for ACR scenarios' -tags 'CI' {
7576
$pkg.Version | Should -BeExactly "1.0.0"
7677
}
7778

79+
It "Install resource when version contains different number of digits than the normalized version- 1 digit specified" {
80+
# the resource has version "1.0", but querying with any equivalent version should work
81+
Install-PSResource -Name $testModuleWith2DigitVersion -Version "1" -Repository $ACRRepoName
82+
$res = Get-InstalledPSResource -Name $testModuleWith2DigitVersion
83+
$res | Should -Not -BeNullOrEmpty
84+
$res.Version | Should -Be "1.0"
85+
}
86+
87+
It "Install resource when version contains different number of digits than the normalized version- 2 digits specified" {
88+
# the resource has version "1.0", but querying with any equivalent version should work
89+
Install-PSResource -Name $testModuleWith2DigitVersion -Version "1.0" -Repository $ACRRepoName
90+
$res = Get-InstalledPSResource -Name $testModuleWith2DigitVersion
91+
$res | Should -Not -BeNullOrEmpty
92+
$res.Version | Should -Be "1.0"
93+
}
94+
95+
It "Install resource when version contains different number of digits than the normalized version- 3 digits specified" {
96+
# the resource has version "1.0", but querying with any equivalent version should work
97+
Install-PSResource -Name $testModuleWith2DigitVersion -Version "1.0.0" -Repository $ACRRepoName
98+
$res = Get-InstalledPSResource -Name $testModuleWith2DigitVersion
99+
$res | Should -Not -BeNullOrEmpty
100+
$res.Version | Should -Be "1.0"
101+
}
102+
103+
It "Install resource when version contains different number of digits than the normalized version- 4 digits specified" {
104+
# the resource has version "1.0", but querying with any equivalent version should work
105+
Install-PSResource -Name $testModuleWith2DigitVersion -Version "1.0.0.0" -Repository $ACRRepoName
106+
$res = Get-InstalledPSResource -Name $testModuleWith2DigitVersion
107+
$res | Should -Not -BeNullOrEmpty
108+
$res.Version | Should -Be "1.0"
109+
}
110+
78111
It "Install multiple resources by name" {
79112
$pkgNames = @($testModuleName, $testModuleName2)
80113
Install-PSResource -Name $pkgNames -Repository $ACRRepoName -TrustRepository

0 commit comments

Comments
 (0)