17
17
function SuiteSetup {
18
18
Import-Module " $PSScriptRoot \PSGetTestUtils.psm1" - WarningAction SilentlyContinue
19
19
Import-Module " $PSScriptRoot \Asserts.psm1" - WarningAction SilentlyContinue
20
-
20
+
21
21
$script :IsWindowsOS = (-not (Get-Variable - Name IsWindows - ErrorAction Ignore)) -or $IsWindows
22
22
$script :ProgramFilesModulesPath = Get-AllUsersModulesPath
23
23
$script :MyDocumentsModulesPath = Get-CurrentUserModulesPath
@@ -64,7 +64,7 @@ function SuiteSetup {
64
64
$script :TestPSModulePath = Join-Path - Path $script :TempPath - ChildPath " PSGet_$ ( Get-Random ) "
65
65
$null = New-Item - Path $script :TempModulesPath - ItemType Directory - Force
66
66
$null = New-Item - Path $script :TestPSModulePath - ItemType Directory - Force
67
-
67
+
68
68
# Set up local "gallery"
69
69
$script :localGalleryName = [System.Guid ]::NewGuid().ToString()
70
70
$script :PSGalleryRepoPath = Join-Path - Path $script :TempPath - ChildPath ' PSGalleryRepo'
@@ -88,7 +88,7 @@ function SuiteSetup {
88
88
89
89
$null = New-ModuleManifest - Path (Join-Path - Path $pesterv1Destination - ChildPath " Pester.psd1" ) - Description " Test signed module v1" - ModuleVersion 99.99 .99.98
90
90
$null = New-ModuleManifest - Path (Join-Path - Path $pesterv2Destination - ChildPath " Pester.psd1" ) - Description " Test signed module v2" - ModuleVersion 99.99 .99.99
91
-
91
+
92
92
# Move Pester 3.4.0 to $script:TestPSModulePath
93
93
# If it doesn't exist, attempt to download it.
94
94
# If this is run offline, just fail the test for now.
@@ -150,7 +150,7 @@ function SuiteCleanup {
150
150
}
151
151
}
152
152
}
153
-
153
+
154
154
RemoveItem $script :TempModulesPath
155
155
RemoveItem $script :TestPSModulePath
156
156
}
@@ -172,6 +172,28 @@ Describe PowerShell.PSGet.InstallModuleTests -Tags 'BVT','InnerLoop' {
172
172
PSGetTestUtils\Uninstall-Module DscTestModule
173
173
}
174
174
175
+ # Purpose: InstallShouldBeSilent
176
+ #
177
+ # Action: Install-Module "ContosoServer"
178
+ #
179
+ # Expected Result: Should pass
180
+ #
181
+ It " Install-Module ContosoServer should return be silent" {
182
+ $result = Install-Module - Name " ContosoServer"
183
+ $result | Should - BeNullOrEmpty
184
+ }
185
+
186
+ # Purpose: InstallShouldReturnOutput
187
+ #
188
+ # Action: Install-Module "ContosoServer" -PassThru
189
+ #
190
+ # Expected Result: Should pass
191
+ #
192
+ It " Install-Module ContosoServer -PassThru should return output" {
193
+ $result = Install-Module - Name " ContosoServer" - PassThru
194
+ $result | Should -Not - BeNullOrEmpty
195
+ }
196
+
175
197
# Purpose: InstallNotAvailableModuleWithWildCard
176
198
#
177
199
# Action: Install-Module "Co[nN]t?soS[a-z]r?eW"
@@ -624,7 +646,7 @@ Describe PowerShell.PSGet.InstallModuleTests -Tags 'BVT','InnerLoop' {
624
646
- RedirectStandardOutput $NonAdminConsoleOutput
625
647
waitFor {Test-Path $NonAdminConsoleOutput } - timeoutInMilliseconds $script :assertTimeOutms - exceptionMessage " Install-Module on non-admin console failed to complete"
626
648
$content = Get-Content $NonAdminConsoleOutput
627
-
649
+
628
650
Assert ($content -and ($content -match ' DscTestModule' )) " Install-module with -force should fail when a module version being installed is in use, $content ."
629
651
RemoveItem $NonAdminConsoleOutput
630
652
} `
@@ -847,7 +869,7 @@ Describe PowerShell.PSGet.InstallModuleTests -Tags 'BVT','InnerLoop' {
847
869
848
870
# Because of TFS:1908563, we changed Get-Package to show only the latest version by default
849
871
# hence the count is same after the update.
850
- AssertEquals $modules1.count $modules2.count " module count should be same before and after updating a module, before: $ ( $modules1.count ) , after: $ ( $modules2.count ) "
872
+ AssertEquals $modules1.count $modules2.count " module count should be same before and after updating a module, before: $ ( $modules1.count ) , after: $ ( $modules2.count ) "
851
873
}
852
874
853
875
It ValidateGetInstalledModuleAndUninstallModuleCmdletsWithMinimumVersion {
@@ -1054,7 +1076,7 @@ Describe PowerShell.PSGet.InstallModuleTests.P1 -Tags 'P1','OuterLoop' {
1054
1076
#
1055
1077
# Expected Result: should fail with an error
1056
1078
#
1057
- It " InstallModuleWithRangeWildCards" {
1079
+ It " InstallModuleWithRangeWildCards" {
1058
1080
AssertFullyQualifiedErrorIdEquals - scriptblock {Install-Module - Name " Co[nN]t?soS[a-z]r?er" } `
1059
1081
- expectedFullyQualifiedErrorId ' NameShouldNotContainWildcardCharacters,Install-Module'
1060
1082
}
@@ -1338,28 +1360,28 @@ Describe PowerShell.PSGet.InstallModuleTests.P1 -Tags 'P1','OuterLoop' {
1338
1360
#
1339
1361
It GetInstalledModuleWithWildcard {
1340
1362
$ModuleNames = ' Contoso' , ' ContosoServer' , ' ContosoClient'
1341
-
1363
+
1342
1364
Install-Module - Name $ModuleNames
1343
1365
1344
1366
# ModuleName without wildcards
1345
1367
$res1 = Get-InstalledModule - Name $ModuleNames [0 ]
1346
1368
AssertEquals $res1.Name $ModuleNames [0 ] " Get-InstalledModule didn't return the exact module, $res1 "
1347
-
1369
+
1348
1370
# ModuleName with wildcards
1349
1371
$res2 = Get-InstalledModule - Name " Contoso*"
1350
1372
AssertEquals $res2.count $ModuleNames.Count " Get-InstalledModule didn't return the $ModuleNames modules, $res2 "
1351
1373
}
1352
1374
1353
1375
# Purpose: Validate Install-Module cmdlet with same source location registered with NUGet provider
1354
1376
#
1355
- # Expected Result: Get-InstalledModule should return proper Repository and RepositorySourceLocation values
1377
+ # Expected Result: Get-InstalledModule should return proper Repository and RepositorySourceLocation values
1356
1378
# from the PowerShellGet provider only not from the NuGet provider
1357
1379
#
1358
1380
It InstallModuleWithSameLocationRegisteredWithNuGetProvider {
1359
1381
$ModuleName = ' ContosoServer'
1360
1382
$TempNuGetSourceName = " $ ( Get-Random ) "
1361
1383
$RepositoryName = " PSGallery"
1362
- Register-PackageSource - Provider nuget - Name $TempNuGetSourceName - Location $Global :PSGallerySourceUri - Trusted
1384
+ Register-PackageSource - Provider nuget - Name $TempNuGetSourceName - Location $Global :PSGallerySourceUri - Trusted
1363
1385
try
1364
1386
{
1365
1387
Install-Module - Name $ModuleName - Repository $RepositoryName
@@ -1385,7 +1407,7 @@ Describe PowerShell.PSGet.InstallModuleTests.P1 -Tags 'P1','OuterLoop' {
1385
1407
finally
1386
1408
{
1387
1409
Unregister-PackageSource - ProviderName NuGet - Name $TempNuGetSourceName - Force
1388
- }
1410
+ }
1389
1411
}
1390
1412
1391
1413
# Purpose: Validate Save-Module cmdlet with Find-Command cmdlet output
@@ -1416,7 +1438,7 @@ Describe PowerShell.PSGet.InstallModuleTests.P1 -Tags 'P1','OuterLoop' {
1416
1438
}
1417
1439
1418
1440
Describe PowerShell.PSGet.InstallModuleTests.P2 - Tags ' P2' , ' OuterLoop' {
1419
- # Not executing these tests on MacOS as
1441
+ # Not executing these tests on MacOS as
1420
1442
# the total execution time is exceeding allowed 50 min in TravisCI daily builds.
1421
1443
if ($IsMacOS ) {
1422
1444
return
0 commit comments