@@ -22,17 +22,17 @@ Describe "Test Reset-PSResourceRepository" -tags 'CI' {
2222 $tmpDirPath = Join-Path - Path $TestDrive - ChildPath " tmpDir1"
2323 New-Item - ItemType Directory - Path $tmpDirPath - Force | Out-Null
2424 Register-PSResourceRepository - Name $TestRepoName - Uri $tmpDirPath
25-
25+
2626 # Verify repository was added
2727 $repos = Get-PSResourceRepository
2828 $repos.Count | Should - BeGreaterThan 1
29-
29+
3030 # Act: Reset repository store
3131 Reset-PSResourceRepository - Confirm:$false
32-
32+
3333 # Assert: Only PSGallery should exist
3434 $repos = Get-PSResourceRepository
35- $repos.Count | Should - Be 1
35+ $repos.Count | Should - Be 2
3636 $repos.Name | Should - Be $PSGalleryName
3737 $repos.Uri | Should - Be $PSGalleryUri
3838 }
@@ -43,20 +43,20 @@ Describe "Test Reset-PSResourceRepository" -tags 'CI' {
4343 $tmpDirPath = Join-Path - Path $TestDrive - ChildPath " tmpDir1"
4444 New-Item - ItemType Directory - Path $tmpDirPath - Force | Out-Null
4545 Register-PSResourceRepository - Name $TestRepoName - Uri $tmpDirPath
46-
46+
4747 # Act: Reset repository store with PassThru
4848 $result = Reset-PSResourceRepository - Confirm:$false - PassThru
49-
49+
5050 # Assert: Result should be PSGallery repository info
5151 $result | Should -Not - BeNullOrEmpty
5252 $result.Name | Should - Be $PSGalleryName
5353 $result.Uri | Should - Be $PSGalleryUri
5454 $result.Trusted | Should - Be $false
5555 $result.Priority | Should - Be 50
56-
56+
5757 # Verify only PSGallery exists
5858 $repos = Get-PSResourceRepository
59- $repos.Count | Should - Be 1
59+ $repos.Count | Should - Be 2
6060 }
6161
6262 It " Reset repository store should support -WhatIf" {
@@ -65,14 +65,14 @@ Describe "Test Reset-PSResourceRepository" -tags 'CI' {
6565 $tmpDirPath = Join-Path - Path $TestDrive - ChildPath " tmpDir1"
6666 New-Item - ItemType Directory - Path $tmpDirPath - Force | Out-Null
6767 Register-PSResourceRepository - Name $TestRepoName - Uri $tmpDirPath
68-
68+
6969 # Capture repository count before WhatIf
7070 $reposBefore = Get-PSResourceRepository
7171 $countBefore = $reposBefore.Count
72-
72+
7373 # Act: Run with WhatIf
7474 Reset-PSResourceRepository - WhatIf
75-
75+
7676 # Assert: Repositories should not have changed
7777 $reposAfter = Get-PSResourceRepository
7878 $reposAfter.Count | Should - Be $countBefore
@@ -82,42 +82,42 @@ Describe "Test Reset-PSResourceRepository" -tags 'CI' {
8282 # Arrange: Corrupt the repository file
8383 $powerShellGetPath = Join-Path - Path ([Environment ]::GetFolderPath([System.Environment + SpecialFolder ]::LocalApplicationData)) - ChildPath " PSResourceGet"
8484 $repoFilePath = Join-Path - Path $powerShellGetPath - ChildPath " PSResourceRepository.xml"
85-
85+
8686 # Write invalid XML to corrupt the file
8787 " This is not valid XML" | Set-Content - Path $repoFilePath - Force
88-
88+
8989 # Act: Reset the repository store
9090 $result = Reset-PSResourceRepository - Confirm:$false - PassThru
91-
91+
9292 # Assert: Should successfully reset and return PSGallery
9393 $result | Should -Not - BeNullOrEmpty
9494 $result.Name | Should - Be $PSGalleryName
95-
95+
9696 # Verify we can now read repositories
9797 $repos = Get-PSResourceRepository
98- $repos.Count | Should - Be 1
98+ $repos.Count | Should - Be 2
9999 $repos.Name | Should - Be $PSGalleryName
100100 }
101101
102102 It " Reset repository store when file doesn't exist should succeed" {
103103 # Arrange: Delete the repository file
104104 $powerShellGetPath = Join-Path - Path ([Environment ]::GetFolderPath([System.Environment + SpecialFolder ]::LocalApplicationData)) - ChildPath " PSResourceGet"
105105 $repoFilePath = Join-Path - Path $powerShellGetPath - ChildPath " PSResourceRepository.xml"
106-
106+
107107 if (Test-Path - Path $repoFilePath ) {
108108 Remove-Item - Path $repoFilePath - Force
109109 }
110-
110+
111111 # Act: Reset the repository store
112112 $result = Reset-PSResourceRepository - Confirm:$false - PassThru
113-
113+
114114 # Assert: Should successfully reset and return PSGallery
115115 $result | Should -Not - BeNullOrEmpty
116116 $result.Name | Should - Be $PSGalleryName
117-
117+
118118 # Verify PSGallery is registered
119119 $repos = Get-PSResourceRepository
120- $repos.Count | Should - Be 1
120+ $repos.Count | Should - Be 2
121121 $repos.Name | Should - Be $PSGalleryName
122122 }
123123
@@ -129,21 +129,21 @@ Describe "Test Reset-PSResourceRepository" -tags 'CI' {
129129 New-Item - ItemType Directory - Path $tmpDir1Path - Force | Out-Null
130130 New-Item - ItemType Directory - Path $tmpDir2Path - Force | Out-Null
131131 New-Item - ItemType Directory - Path $tmpDir3Path - Force | Out-Null
132-
132+
133133 Register-PSResourceRepository - Name " testRepo1" - Uri $tmpDir1Path
134134 Register-PSResourceRepository - Name " testRepo2" - Uri $tmpDir2Path
135135 Register-PSResourceRepository - Name " testRepo3" - Uri $tmpDir3Path
136-
136+
137137 # Verify multiple repositories exist
138138 $reposBefore = Get-PSResourceRepository
139139 $reposBefore.Count | Should - BeGreaterThan 1
140-
140+
141141 # Act: Reset repository store
142142 Reset-PSResourceRepository - Confirm:$false
143-
143+
144144 # Assert: Only PSGallery should remain
145145 $reposAfter = Get-PSResourceRepository
146- $reposAfter.Count | Should - Be 1
146+ $reposAfter.Count | Should - Be 2
147147 $reposAfter.Name | Should - Be $PSGalleryName
148148 }
149149}
0 commit comments