Skip to content

Commit d387624

Browse files
🩹 [Patch]: Add pipeline input to Disconnect-GitHub (#213)
## Description This pull request includes changes to improve the structure and organization of tests. The most important changes include adding support for pipeline input of contexts to `Disconnect-GitHubAccount`, restructuring test descriptions for better organization, and removing redundant test files. Changes to parameter attributes: * [`src/functions/public/Auth/Disconnect-GitHubAccount.ps1`](diffhunk://#diff-3774b57dfa8d10fd0436e4abdecba2520b9dc8ae12c39e8b10f3ccb782b40898L45-R45): Changed the `[Parameter()]` attribute to `[Parameter(ValueFromPipeline)]` for the `$Context` parameter. Restructuring of test descriptions: * [`tests/GitHub.Tests.ps1`](diffhunk://#diff-0b1d9ba345a583adce874126c13d6edd3f789416bb9c4db5df1e18af3608554cL170-R170): Replaced `Describe` blocks with `Context` blocks for better organization and added new contexts for `Rate-Limit`, `Repository`, `Status`, and `Disconnect` tests. [[1]](diffhunk://#diff-0b1d9ba345a583adce874126c13d6edd3f789416bb9c4db5df1e18af3608554cL170-R170) [[2]](diffhunk://#diff-0b1d9ba345a583adce874126c13d6edd3f789416bb9c4db5df1e18af3608554cR191-R272) Removal of redundant test files: * [`tests/GitHub/Get-GitHubRepository.Tests.ps1`](diffhunk://#diff-f0b2049f7b6fdce5eb0ddde9c3f58cfda88f362d6f02ceddc9112355d712fbe3L1-L45): Removed redundant test file as its tests were consolidated into `tests/GitHub.Tests.ps1`. * [`tests/GitHub/Status/Get-GitHubScheduledMaintenance.Tests.ps1`](diffhunk://#diff-b4ff390053acf09079119ae21340da191055577d8e5d774822972136d168153bL1-L23): Removed redundant test file as its tests were consolidated into `tests/GitHub.Tests.ps1`. * [`tests/GitHub/Status/Get-GitHubStatus.Tests.ps1`](diffhunk://#diff-7a206609b1f6d29b7de646678566b2e07ada8227d1d113e0ec28159934be442eL1-L17): Removed redundant test file as its tests were consolidated into `tests/GitHub.Tests.ps1`. * [`tests/GitHub/Status/Get-GitHubStatusComponent.Tests.ps1`](diffhunk://#diff-591e71c140b769a472edc57bddb19fd5e1f5d9992bae625282b198644666a917L1-L9): Removed redundant test file as its tests were consolidated into `tests/GitHub.Tests.ps1`. * [`tests/GitHub/Status/Get-GitHubStatusIncident.Tests.ps1`](diffhunk://#diff-550aed18013a4bc4ac4b71412efc090fa1b9d821dfc33a1cc51d72ef0beffaf4L1-L17): Removed redundant test file as its tests were consolidated into `tests/GitHub.Tests.ps1`. * [`tests/Rate-Limit/Get-GitHubRateLimit.Tests.ps1`](diffhunk://#diff-eda17a19352d3fd8eadc53b0a221326decff2a7b496ebf0c2ceb8be687d89262L1-L9): Removed redundant test file as its tests were consolidated into `tests/GitHub.Tests.ps1`. ## Type of change <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] 📖 [Docs] - [ ] 🪲 [Fix] - [x] 🩹 [Patch] - [ ] ⚠️ [Security fix] - [ ] 🚀 [Feature] - [ ] 🌟 [Breaking change] ## Checklist <!-- Use the check-boxes [x] on the options that are relevant. --> - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas
1 parent dca1183 commit d387624

File tree

8 files changed

+84
-122
lines changed

8 files changed

+84
-122
lines changed

src/functions/public/Auth/Disconnect-GitHubAccount.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
# The context to run the command with.
4444
# Can be either a string or a GitHubContext object.
45-
[Parameter()]
45+
[Parameter(ValueFromPipeline)]
4646
[object] $Context = (Get-GitHubContext)
4747
)
4848

tests/GitHub.Tests.ps1

Lines changed: 83 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ Describe 'GitHub' {
167167

168168
}
169169
}
170-
Describe 'Commands' {
170+
Context 'Commands' {
171171
It "Start-LogGroup 'MyGroup' should not throw" {
172172
{
173173
Start-LogGroup 'MyGroup'
@@ -188,4 +188,86 @@ Describe 'GitHub' {
188188
} | Should -Not -Throw
189189
}
190190
}
191+
Context 'Rate-Limit' {
192+
It 'Can be called with no parameters' {
193+
{ Get-GitHubRateLimit } | Should -Not -Throw
194+
}
195+
}
196+
Context 'Repository' {
197+
It 'Function exists' {
198+
Get-Command Get-GitHubRepository | Should -Not -BeNullOrEmpty
199+
}
200+
201+
# Context 'Parameter Set: MyRepos_Type' {
202+
# It 'Can be called with no parameters' {
203+
# { Get-GitHubRepository - } | Should -Not -Throw
204+
# }
205+
206+
# It 'Can be called with Type parameter' {
207+
# { Get-GitHubRepository -Type 'public' } | Should -Not -Throw
208+
# }
209+
# }
210+
211+
# Context 'Parameter Set: MyRepos_Aff-Vis' {
212+
# It 'Can be called with Visibility and Affiliation parameters' {
213+
# { Get-GitHubRepository -Visibility 'public' -Affiliation 'owner' } | Should -Not -Throw
214+
# }
215+
# }
216+
217+
It 'Can be called with Owner and Repo parameters' {
218+
{ Get-GitHubRepository -Owner 'PSModule' -Repo 'GitHub' } | Should -Not -Throw
219+
}
220+
221+
# Context 'Parameter Set: ListByID' {
222+
# It 'Can be called with SinceID parameter' {
223+
# { Get-GitHubRepository -SinceID 123456789 } | Select-Object -First 10 | Should -Not -Throw
224+
# }
225+
# }
226+
227+
It 'Can be called with Owner parameter' {
228+
{ Get-GitHubRepository -Owner 'PSModule' } | Should -Not -Throw
229+
}
230+
231+
It 'Can be called with Username parameter' {
232+
{ Get-GitHubRepository -Username 'MariusStorhaug' } | Should -Not -Throw
233+
}
234+
}
235+
Context 'Status' {
236+
It 'Can be called with no parameters' {
237+
{ Get-GitHubScheduledMaintenance } | Should -Not -Throw
238+
}
239+
It 'Can be called with Active parameter' {
240+
{ Get-GitHubScheduledMaintenance -Active } | Should -Not -Throw
241+
}
242+
It 'Can be called with Upcoming parameter' {
243+
{ Get-GitHubScheduledMaintenance -Upcoming } | Should -Not -Throw
244+
}
245+
It 'Can be called with no parameters' {
246+
{ Get-GitHubStatus } | Should -Not -Throw
247+
}
248+
It 'Can be called with Summary parameter' {
249+
{ Get-GitHubStatus -Summary } | Should -Not -Throw
250+
}
251+
It 'Function exists' {
252+
Get-Command Get-GitHubStatusComponent | Should -Not -BeNullOrEmpty
253+
}
254+
It 'Can be called with no parameters' {
255+
{ Get-GitHubStatusComponent } | Should -Not -Throw
256+
}
257+
It 'Function exists' {
258+
Get-Command Get-GitHubStatusIncident | Should -Not -BeNullOrEmpty
259+
}
260+
It 'Can be called with no parameters' {
261+
{ Get-GitHubStatusIncident } | Should -Not -Throw
262+
}
263+
It 'Can be called with Unresolved parameter' {
264+
{ Get-GitHubStatusIncident -Unresolved } | Should -Not -Throw
265+
}
266+
}
267+
Context 'Disconnect' {
268+
It 'Can disconnect without parameters' {
269+
{ Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount } | Should -Not -Throw
270+
Get-GitHubContext -ListAvailable | Should -HaveCount 0
271+
}
272+
}
191273
}

tests/GitHub/Get-GitHubRepository.Tests.ps1

Lines changed: 0 additions & 45 deletions
This file was deleted.

tests/GitHub/Status/Get-GitHubScheduledMaintenance.Tests.ps1

Lines changed: 0 additions & 23 deletions
This file was deleted.

tests/GitHub/Status/Get-GitHubStatus.Tests.ps1

Lines changed: 0 additions & 17 deletions
This file was deleted.

tests/GitHub/Status/Get-GitHubStatusComponent.Tests.ps1

Lines changed: 0 additions & 9 deletions
This file was deleted.

tests/GitHub/Status/Get-GitHubStatusIncident.Tests.ps1

Lines changed: 0 additions & 17 deletions
This file was deleted.

tests/Rate-Limit/Get-GitHubRateLimit.Tests.ps1

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)