Skip to content

Commit 7f24c34

Browse files
committed
Add flaky tests to Release run only
1 parent 8f05b25 commit 7f24c34

5 files changed

Lines changed: 137 additions & 58 deletions

test/FindPSResourceTests/FindPSResourceContainerRegistryServer.Tests.ps1

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -298,18 +298,6 @@ Describe 'Test Find-PSResource for MAR Repository' -tags 'CI' {
298298
$res.Dependencies.Length | Should -Not -Be 0
299299
}
300300

301-
It "Should find resource with wildcard in Name" {
302-
$res = Find-PSResource -Name "Az.App*" -Repository "MAR"
303-
$res | Should -Not -BeNullOrEmpty
304-
$res.Count | Should -BeGreaterThan 1
305-
}
306-
307-
It "Should find all resource with wildcard in Name" {
308-
$res = Find-PSResource -Name "*" -Repository "MAR"
309-
$res | Should -Not -BeNullOrEmpty
310-
$res.Count | Should -BeGreaterThan 1
311-
}
312-
313301
It "Should find version range for Az dependencies" {
314302
# Target known version to know the output from the API won't change
315303
$res = Find-PSResource -Repository 'MAR' -Name 'Az' -Version '14.4.0'

test/FindPSResourceTests/FindPSResourceRepositorySearching.Tests.ps1

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -531,33 +531,6 @@ Describe 'Test Find-PSResource for searching and looping through repositories' -
531531
$pkgFoundFromPSGallery | Should -BeTrue
532532
}
533533

534-
It "find resources from all pattern matching repositories where it exists (-Repository with wildcard)" {
535-
# Package with CommandName "Get-TargetResource" exists in the following repositories: PSGallery, localRepo
536-
$res = Find-PSResource -CommandName $cmdName -Repository "*Gallery" -ErrorVariable err -ErrorAction SilentlyContinue
537-
$err | Should -HaveCount 0
538-
$res.Count | Should -BeGreaterOrEqual 9
539-
540-
$pkgFoundFromLocalRepo = $false
541-
$pkgFoundFromPSGallery = $false
542-
543-
foreach ($pkg in $res)
544-
{
545-
if ($pkg.ParentResource.Repository -eq $localRepoName)
546-
{
547-
$pkgFoundFromLocalRepo = $true
548-
}
549-
elseif ($pkg.ParentResource.Repository -eq $PSGalleryName)
550-
{
551-
$pkgFoundFromPSGallery = $true
552-
}
553-
}
554-
555-
$pkg.Names | Should -Be $cmdName
556-
$pkg.ParentResource.Includes.Command | Should -Contain $cmdName
557-
$pkgFoundFromLocalRepo | Should -BeFalse
558-
$pkgFoundFromPSGallery | Should -BeTrue
559-
}
560-
561534
It "should not allow for repository name with wildcard and non-wildcard command name specified in same command run" {
562535
{Find-PSResource -CommandName $cmdName -Repository "*Gallery",$localRepoName} | Should -Throw -ErrorId "RepositoryNamesWithWildcardsAndNonWildcardUnsupported,Microsoft.PowerShell.PSResourceGet.Cmdlets.FindPSResource"
563536
}

test/FindPSResourceTests/FindPSResourceV2Server.Tests.ps1

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -353,24 +353,6 @@ Describe 'Test HTTP Find-PSResource for V2 Server Protocol' -tags 'CI' {
353353
$res | Should -HaveCount 2
354354
}
355355

356-
It "find resource given CommandName" {
357-
$res = Find-PSResource -CommandName $commandName -Repository $PSGalleryName
358-
$res | Should -Not -BeNullOrEmpty
359-
foreach ($item in $res) {
360-
$item.Names | Should -Be $commandName
361-
$item.ParentResource.Includes.Command | Should -Contain $commandName
362-
}
363-
}
364-
365-
It "find resource given DscResourceName" {
366-
$res = Find-PSResource -DscResourceName $dscResourceName -Repository $PSGalleryName
367-
$res | Should -Not -BeNullOrEmpty
368-
foreach ($item in $res) {
369-
$item.Names | Should -Be $dscResourceName
370-
$item.ParentResource.Includes.DscResource | Should -Contain $dscResourceName
371-
}
372-
}
373-
374356
It "find resource, but only show listed versions" {
375357
# testmodule99 version 1.0.0-beta1 is unlisted
376358
$res = Find-PSResource -Name "testmodule99" -Repository $PSGalleryName

test/InstallPSResourceTests/InstallPSResourceContainerRegistryServer.Tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ Describe 'Test Install-PSResource for ACR scenarios' -tags 'CI' {
166166
$Version = "(1.0.0.0)"
167167
{ Install-PSResource -Name $testModuleName -Version $Version -Repository $ACRRepoName -TrustRepository -ErrorAction SilentlyContinue } | Should -Throw -ErrorId "IncorrectVersionFormat,Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallPSResource"
168168

169-
$res = Get-InstalledPSResource $testModuleName
169+
$res = Get-InstalledPSResource $testModuleName -ErrorAction Ignore
170170
$res | Should -BeNullOrEmpty
171171
}
172172

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
3+
4+
$modPath = "$psscriptroot/../PSGetTestUtils.psm1"
5+
Import-Module $modPath -Force -Verbose
6+
7+
$psmodulePaths = $env:PSModulePath -split ';'
8+
Write-Verbose -Verbose "Current module search paths: $psmodulePaths"
9+
10+
11+
Describe 'Test Find-PSResource for MAR Repository' -tags 'Release' {
12+
BeforeAll {
13+
Register-PSResourceRepository -Name "MAR" -Uri "https://mcr.microsoft.com" -ApiVersion "ContainerRegistry"
14+
}
15+
16+
AfterAll {
17+
Unregister-PSResourceRepository -Name "MAR"
18+
}
19+
20+
It "Should find resource with wildcard in Name" {
21+
$res = Find-PSResource -Name "Az.App*" -Repository "MAR"
22+
$res | Should -Not -BeNullOrEmpty
23+
$res.Count | Should -BeGreaterThan 1
24+
}
25+
26+
It "Should find all resource with wildcard in Name" {
27+
$res = Find-PSResource -Name "*" -Repository "MAR"
28+
$res | Should -Not -BeNullOrEmpty
29+
$res.Count | Should -BeGreaterThan 1
30+
}
31+
32+
}
33+
34+
35+
Describe 'Test Find-PSResource for searching and looping through repositories' -tags 'Release' {
36+
37+
BeforeAll{
38+
$testModuleName = "test_module"
39+
$testModuleName2 = "test_module2"
40+
$testCmdDSCParentPkg = "myCmdDSCModule"
41+
$testScriptName = "test_script"
42+
43+
$tag1 = "CommandsAndResource"
44+
$tag2 = "Tag-Required-Script1-2.5"
45+
46+
$cmdName = "Get-TargetResource"
47+
$dscName = "SystemLocale"
48+
$tagsEscaped = @("'$tag1'", "'PSCommand_$cmdName'", "'PSDscResource_$dscName'")
49+
50+
$cmdName2 = "Get-MyCommand"
51+
$dscName2 = "MyDSCResource"
52+
$tagsEscaped2 = @("'PSCommand_$cmdName2'", "'PSDscResource_$dscName2'")
53+
54+
$PSGalleryName = "PSGallery"
55+
$NuGetGalleryName = "NuGetGallery"
56+
$localRepoName = "localRepo"
57+
58+
Get-NewPSResourceRepositoryFile
59+
60+
$localRepoUriAddress = Join-Path -Path $TestDrive -ChildPath "testdir"
61+
$null = New-Item $localRepoUriAddress -ItemType Directory -Force
62+
Register-PSResourceRepository -Name $localRepoName -Uri $localRepoUriAddress
63+
64+
New-TestModule -moduleName $testModuleName -repoName localRepo -packageVersion "1.0.0" -prereleaseLabel "" -tags $tagsEscaped
65+
New-TestModule -moduleName $testCmdDSCParentPkg -repoName localRepo -packageVersion "1.0.0" -prereleaseLabel "" -tags $tagsEscaped2
66+
}
67+
68+
AfterAll {
69+
Get-RevertPSResourceRepositoryFile
70+
}
71+
72+
It "find resources from all pattern matching repositories where it exists (-Repository with wildcard)" {
73+
# Package with CommandName "Get-TargetResource" exists in the following repositories: PSGallery, localRepo
74+
$res = Find-PSResource -CommandName $cmdName -Repository "*Gallery" -ErrorVariable err -ErrorAction SilentlyContinue
75+
$err | Should -HaveCount 0
76+
$res.Count | Should -BeGreaterOrEqual 9
77+
78+
$pkgFoundFromLocalRepo = $false
79+
$pkgFoundFromPSGallery = $false
80+
81+
foreach ($pkg in $res)
82+
{
83+
if ($pkg.ParentResource.Repository -eq $localRepoName)
84+
{
85+
$pkgFoundFromLocalRepo = $true
86+
}
87+
elseif ($pkg.ParentResource.Repository -eq $PSGalleryName)
88+
{
89+
$pkgFoundFromPSGallery = $true
90+
}
91+
}
92+
93+
$pkg.Names | Should -Be $cmdName
94+
$pkg.ParentResource.Includes.Command | Should -Contain $cmdName
95+
$pkgFoundFromLocalRepo | Should -BeFalse
96+
$pkgFoundFromPSGallery | Should -BeTrue
97+
}
98+
99+
}
100+
101+
102+
103+
Describe 'Test HTTP Find-PSResource for V2 Server Protocol' -tags 'Release' {
104+
105+
BeforeAll{
106+
$PSGalleryName = Get-PSGalleryName
107+
$testModuleName = "test_module"
108+
$testScriptName = "test_script"
109+
$commandName = "Get-TargetResource"
110+
$dscResourceName = "SystemLocale"
111+
$parentModuleName = "SystemLocaleDsc"
112+
Get-NewPSResourceRepositoryFile
113+
}
114+
115+
AfterAll {
116+
Get-RevertPSResourceRepositoryFile
117+
}
118+
119+
It "find resource given CommandName" {
120+
$res = Find-PSResource -CommandName $commandName -Repository $PSGalleryName
121+
$res | Should -Not -BeNullOrEmpty
122+
foreach ($item in $res) {
123+
$item.Names | Should -Be $commandName
124+
$item.ParentResource.Includes.Command | Should -Contain $commandName
125+
}
126+
}
127+
128+
It "find resource given DscResourceName" {
129+
$res = Find-PSResource -DscResourceName $dscResourceName -Repository $PSGalleryName
130+
$res | Should -Not -BeNullOrEmpty
131+
foreach ($item in $res) {
132+
$item.Names | Should -Be $dscResourceName
133+
$item.ParentResource.Includes.DscResource | Should -Contain $dscResourceName
134+
}
135+
}
136+
}

0 commit comments

Comments
 (0)