1
1
# Copyright (c) Microsoft Corporation.
2
2
# Licensed under the MIT License.
3
3
4
+ [Diagnostics.CodeAnalysis.SuppressMessageAttribute (' PSUseDeclaredVarsMoreThanAssignments' , ' ' )]
5
+ Param ()
6
+
4
7
$ProgressPreference = " SilentlyContinue"
5
8
$modPath = " $psscriptroot /../PSGetTestUtils.psm1"
6
9
Import-Module $modPath - Force - Verbose
7
10
8
11
$psmodulePaths = $env: PSModulePath -split ' ;'
9
- Write-Verbose - Verbose " Current module search paths: $psmodulePaths "
12
+ Write-Verbose - Verbose - Message " Current module search paths: $psmodulePaths "
10
13
11
14
Describe ' Test Install-PSResource for local repositories' - tags ' CI' {
12
15
13
-
14
16
BeforeAll {
15
17
$localRepo = " psgettestlocal"
16
18
$localUNCRepo = " psgettestlocal3"
@@ -54,7 +56,7 @@ Describe 'Test Install-PSResource for local repositories' -tags 'CI' {
54
56
$res.Version | Should - Be " 5.0.0"
55
57
}
56
58
57
- It " Install resource given Name parameter from UNC repository" {
59
+ It " Install resource given Name parameter from UNC repository" {
58
60
Install-PSResource - Name $testModuleName - Repository $localUNCRepo - TrustRepository
59
61
$res = Get-InstalledPSResource - Name $testModuleName
60
62
$res.Name | Should - Be $testModuleName
@@ -70,7 +72,7 @@ Describe 'Test Install-PSResource for local repositories' -tags 'CI' {
70
72
71
73
It " Install multiple resources by name" {
72
74
$pkgNames = @ ($testModuleName , $testModuleName2 )
73
- Install-PSResource - Name $pkgNames - Repository $localRepo - TrustRepository
75
+ Install-PSResource - Name $pkgNames - Repository $localRepo - TrustRepository
74
76
$pkg = Get-InstalledPSResource $pkgNames
75
77
$pkg.Name | Should - Be $pkgNames
76
78
}
@@ -83,7 +85,7 @@ Describe 'Test Install-PSResource for local repositories' -tags 'CI' {
83
85
}
84
86
85
87
It " Should install resource given name and exact version with bracket syntax" {
86
- Install-PSResource - Name $testModuleName - Version " [1.0.0.0]" - Repository $localRepo - TrustRepository
88
+ Install-PSResource - Name $testModuleName - Version " [1.0.0.0]" - Repository $localRepo - TrustRepository
87
89
$res = Get-InstalledPSResource $testModuleName
88
90
$res.Name | Should - Be $testModuleName
89
91
$res.Version | Should - Be " 1.0.0"
@@ -97,7 +99,7 @@ Describe 'Test Install-PSResource for local repositories' -tags 'CI' {
97
99
}
98
100
99
101
It " Should install resource given name and exact range exclusive (1.0.0.0, 5.0.0.0)" {
100
- Install-PSResource - Name $testModuleName - Version " (1.0.0.0, 5.0.0.0)" - Repository $localRepo - TrustRepository
102
+ Install-PSResource - Name $testModuleName - Version " (1.0.0.0, 5.0.0.0)" - Repository $localRepo - TrustRepository
101
103
$res = Get-InstalledPSResource $testModuleName
102
104
$res.Name | Should - Be $testModuleName
103
105
$res.Version | Should - Be " 3.0.0"
@@ -110,7 +112,7 @@ Describe 'Test Install-PSResource for local repositories' -tags 'CI' {
110
112
}
111
113
catch
112
114
{}
113
- $Error [0 ].FullyQualifiedErrorId | Should - be " IncorrectVersionFormat,Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallPSResource"
115
+ $Error [0 ].FullyQualifiedErrorId | Should - Be " IncorrectVersionFormat,Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallPSResource"
114
116
115
117
$res = Get-InstalledPSResource $testModuleName - ErrorAction SilentlyContinue
116
118
$res | Should - BeNullOrEmpty
@@ -131,7 +133,7 @@ Describe 'Test Install-PSResource for local repositories' -tags 'CI' {
131
133
}
132
134
133
135
It " Install resource with latest (including prerelease) version given Prerelease parameter" {
134
- Install-PSResource - Name $testModuleName - Prerelease - Repository $localRepo - TrustRepository
136
+ Install-PSResource - Name $testModuleName - Prerelease - Repository $localRepo - TrustRepository
135
137
$pkg = Get-InstalledPSResource $testModuleName
136
138
$pkg.Name | Should - Be $testModuleName
137
139
$pkg.Version | Should - Be " 5.2.5"
@@ -171,14 +173,14 @@ Describe 'Test Install-PSResource for local repositories' -tags 'CI' {
171
173
}
172
174
173
175
It " Install resource via InputObject by piping from Find-PSresource" {
174
- Find-PSResource - Name $testModuleName - Repository $localRepo | Install-PSResource - TrustRepository
176
+ Find-PSResource - Name $testModuleName - Repository $localRepo | Install-PSResource - TrustRepository
175
177
$pkg = Get-InstalledPSResource $testModuleName
176
178
$pkg.Name | Should - Be $testModuleName
177
179
$pkg.Version | Should - Be " 5.0.0"
178
180
}
179
181
180
182
It " Install resource via InputObject by piping from Find-PSResource" {
181
- $modules = Find-PSResource - Name " *" - Repository $localRepo
183
+ $modules = Find-PSResource - Name " *" - Repository $localRepo
182
184
$modules.Count | Should - BeGreaterThan 1
183
185
184
186
Install-PSResource - TrustRepository - InputObject $modules
@@ -190,7 +192,7 @@ Describe 'Test Install-PSResource for local repositories' -tags 'CI' {
190
192
It " Install resource under location specified in PSModulePath" {
191
193
Install-PSResource - Name $testModuleName - Repository $localRepo - TrustRepository
192
194
$pkg = Get-InstalledPSResource $testModuleName
193
- $pkg.Name | Should - Be $testModuleName
195
+ $pkg.Name | Should - Be $testModuleName
194
196
($env: PSModulePath ).Contains($pkg.InstalledLocation )
195
197
}
196
198
@@ -212,7 +214,7 @@ Describe 'Test Install-PSResource for local repositories' -tags 'CI' {
212
214
213
215
# Windows only
214
216
It " Install resource under no specified scope - Windows only" - Skip:(! (Get-IsWindows )) {
215
- Install-PSResource - Name $testModuleName - Repository $localRepo - TrustRepository
217
+ Install-PSResource - Name $testModuleName - Repository $localRepo - TrustRepository
216
218
$pkg = Get-InstalledPSResource $testModuleName
217
219
$pkg.Name | Should - Be $testModuleName
218
220
$pkg.InstalledLocation.ToString ().Contains(" Documents" ) | Should - Be $true
@@ -240,7 +242,7 @@ Describe 'Test Install-PSResource for local repositories' -tags 'CI' {
240
242
Install-PSResource - Name $testModuleName - Repository $localRepo - TrustRepository
241
243
$pkg = Get-InstalledPSResource $testModuleName
242
244
$pkg.Name | Should - Be $testModuleName
243
- Install-PSResource - Name $testModuleName - Repository $localRepo - TrustRepository - WarningVariable WarningVar - warningaction SilentlyContinue
245
+ Install-PSResource - Name $testModuleName - Repository $localRepo - TrustRepository - WarningVariable WarningVar - WarningAction SilentlyContinue
244
246
$WarningVar | Should -Not - BeNullOrEmpty
245
247
}
246
248
@@ -257,6 +259,8 @@ Describe 'Test Install-PSResource for local repositories' -tags 'CI' {
257
259
258
260
It " Install module using -WhatIf, should not install the module" {
259
261
Install-PSResource - Name $testModuleName - Version " 1.0.0.0" - Repository $localRepo - TrustRepository - WhatIf
262
+ $? | Should - BeTrue
263
+
260
264
$res = Get-InstalledPSResource - Name $testModuleName - ErrorAction SilentlyContinue
261
265
$res | Should - BeNullOrEmpty
262
266
}
@@ -270,11 +274,11 @@ Describe 'Test Install-PSResource for local repositories' -tags 'CI' {
270
274
It " Get definition for alias 'isres'" {
271
275
(Get-Alias isres).Definition | Should - BeExactly ' Install-PSResource'
272
276
}
273
-
277
+
274
278
It " Not install resource that lists dependency packages which cannot be found" {
275
279
$localRepoUri = Join-Path - Path $TestDrive - ChildPath " testdir"
276
280
Save-PSResource - Name " test_script" - Repository " PSGallery" - TrustRepository - Path $localRepoUri - AsNupkg - SkipDependencyCheck
277
- Write-Host $localRepoUri
281
+ Write-Information - InformationAction Continue - MessageData $localRepoUri
278
282
$res = Install-PSResource - Name " test_script" - Repository $localRepo - TrustRepository - PassThru - ErrorVariable err - ErrorAction SilentlyContinue
279
283
$res | Should - BeNullOrEmpty
280
284
$err.Count | Should -Not - Be 0
0 commit comments