Skip to content

Commit 6fea187

Browse files
authored
Update tests to use PowerShell pipeline cmdlets (#570)
1 parent b40e987 commit 6fea187

File tree

1 file changed

+10
-50
lines changed

1 file changed

+10
-50
lines changed

test/FindPSResource.Tests.ps1

Lines changed: 10 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -55,61 +55,21 @@ Describe 'Test Find-PSResource for Module' {
5555
}
5656

5757
It "should find all resources given Name that equals wildcard, '*'" {
58-
$foundPreview = $False
59-
$foundTestScript = $False
60-
$foundTestModule = $False
61-
$res = Find-PSResource -Name "*" -Repository $TestGalleryName
62-
#should find Module and Script resources
63-
foreach ($item in $res)
64-
{
65-
if ($item.Name -eq $testModuleName)
66-
{
67-
$foundTestModule = $True
68-
}
58+
$foundResources = Find-PSResource -Name "*" -Repository "PoshTestGallery"
6959

70-
if ($item.Name -eq $testScriptName)
71-
{
72-
$foundTestScript = $True
73-
}
74-
75-
if($item.IsPrerelease)
76-
{
77-
$foundPreview = $True
78-
}
79-
}
80-
81-
$foundPreview | Should -Be $False
82-
$foundTestScript | Should -Be $True
83-
$foundTestModule | Should -Be $True
60+
# Should find Module and Script resources but no prerelease resources
61+
$foundResources | where-object Name -eq "test_module" | Should -Not -BeNullOrEmpty -Because "test_module should exist in PoshTestGallery"
62+
$foundResources | where-object Name -eq "test_script" | Should -Not -BeNullOrEmpty -Because "test_script should exist in PoshTestGallery"
63+
$foundResources | where-object IsPrerelease -eq $true | Should -BeNullOrEmpty -Because "No prerelease resources should be returned"
8464
}
8565

8666
It "should find all resources (including prerelease) given Name that equals wildcard, '*' and Prerelease parameter" {
87-
$foundPreview = $False
88-
$foundTestScript = $False
89-
$foundTestModule = $False
90-
$res = Find-PSResource -Name "*" -Prerelease -Repository $TestGalleryName
91-
#should find Module and Script resources
92-
foreach ($item in $res)
93-
{
94-
if ($item.Name -eq $testModuleName)
95-
{
96-
$foundTestModule = $True
97-
}
67+
$foundResources = Find-PSResource -Name "*" -Prerelease -Repository "PoshTestGallery"
9868

99-
if ($item.Name -eq $testScriptName)
100-
{
101-
$foundTestScript = $True
102-
}
103-
104-
if($item.IsPrerelease)
105-
{
106-
$foundPreview = $True
107-
}
108-
}
109-
110-
$foundPreview | Should -Be $True
111-
$foundTestScript | Should -Be $True
112-
$foundTestModule | Should -Be $True
69+
# Should find Module and Script resources inlcuding prerelease resources
70+
$foundResources | where-object Name -eq "test_module" | Should -Not -BeNullOrEmpty -Because "test_module should exist in PoshTestGallery"
71+
$foundResources | where-object Name -eq "test_script" | Should -Not -BeNullOrEmpty -Because "test_script should exist in PoshTestGallery"
72+
$foundResources | where-object IsPrerelease -eq $true | Should -Not -BeNullOrEmpty -Because "Prerelease resources should be returned"
11373
}
11474

11575
It "find resource given Name from V3 endpoint repository (NuGetGallery)" {

0 commit comments

Comments
 (0)