From 8f5beaa6ee68d15511d62f7e77778d2103171926 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 24 Dec 2024 14:19:52 +0100 Subject: [PATCH 01/16] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Update=20parame?= =?UTF-8?q?ter=20set=20name=20in=20Get-GitHubUser=20function=20and=20enhan?= =?UTF-8?q?ce=20Get-GitHubUserCard=20examples;=20add=20tests=20for=20user?= =?UTF-8?q?=20retrieval=20functionality?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/functions/public/Users/Get-GitHubUser.ps1 | 4 +- .../public/Users/Get-GitHubUserCard.ps1 | 1 + tests/GitHub.Tests.ps1 | 63 +++++++++++++++++++ 3 files changed, 66 insertions(+), 2 deletions(-) diff --git a/src/functions/public/Users/Get-GitHubUser.ps1 b/src/functions/public/Users/Get-GitHubUser.ps1 index 89de4f409..b912256e4 100644 --- a/src/functions/public/Users/Get-GitHubUser.ps1 +++ b/src/functions/public/Users/Get-GitHubUser.ps1 @@ -33,7 +33,7 @@ 'All', Justification = 'Parameter is used in dynamic parameter validation.' )] - [CmdletBinding(DefaultParameterSetName = '__DefaultSet')] + [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] param( # The handle for the GitHub user account. [Parameter( @@ -75,7 +75,7 @@ process { try { switch ($PSCmdlet.ParameterSetName) { - '__DefaultSet' { + '__AllParameterSets' { $user = Get-GitHubMyUser -Context $Context $social_accounts = Get-GitHubMyUserSocials -Context $Context $user | Add-Member -MemberType NoteProperty -Name 'social_accounts' -Value $social_accounts -Force diff --git a/src/functions/public/Users/Get-GitHubUserCard.ps1 b/src/functions/public/Users/Get-GitHubUserCard.ps1 index b921fd79f..4c0ca1e12 100644 --- a/src/functions/public/Users/Get-GitHubUserCard.ps1 +++ b/src/functions/public/Users/Get-GitHubUserCard.ps1 @@ -17,6 +17,7 @@ ``` .EXAMPLE + Get-GitHubUserCard -Username 'octocat' -SubjectType 'repository' -SubjectID 1300192 .NOTES [Get contextual information for a user](https://docs.github.com/rest/users/users#get-contextual-information-for-a-user) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index f61242e45..e48309755 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -378,6 +378,18 @@ Describe 'As a user - Fine-grained PAT token - user account access' { { Get-GitHubMarkdownRaw -Text 'Hello, World!' } | Should -Not -Throw } } + Context 'User' { + It 'Can be called with no parameters' { + { Get-GitHubUser } | Should -Not -Throw + } + It 'Can be called with Username parameter' { + { Get-GitHubUser -Username 'Octocat' } | Should -Not -Throw + } + It 'Can be called with no parameters' { + $repo = Get-GitHubRepository -Owner 'PSModule' -Repo 'GitHub' + { Get-GitHubUserCard -Username 'MariusStorhaug' -SubjectType repository -SubjectID $repo.id } | Should -Not -Throw + } + } } Describe 'As a user - Fine-grained PAT token - organization account access' { @@ -497,6 +509,18 @@ Describe 'As a user - Fine-grained PAT token - organization account access' { { Get-GitHubMarkdownRaw -Text 'Hello, **World**' } | Should -Not -Throw } } + Context 'User' { + It 'Can be called with no parameters' { + { Get-GitHubUser } | Should -Not -Throw + } + It 'Can be called with Username parameter' { + { Get-GitHubUser -Username 'Octocat' } | Should -Not -Throw + } + It 'Can be called with no parameters' { + $repo = Get-GitHubRepository -Owner 'PSModule' -Repo 'GitHub' + { Get-GitHubUserCard -Username 'MariusStorhaug' -SubjectType repository -SubjectID $repo.id } | Should -Not -Throw + } + } } Describe 'As a user - Classic PAT token' { @@ -593,6 +617,18 @@ Describe 'As a user - Classic PAT token' { { Get-GitHubMarkdownRaw -Text 'Hello, World!' } | Should -Not -Throw } } + Context 'User' { + It 'Can be called with no parameters' { + { Get-GitHubUser } | Should -Not -Throw + } + It 'Can be called with Username parameter' { + { Get-GitHubUser -Username 'Octocat' } | Should -Not -Throw + } + It 'Can be called with no parameters' { + $repo = Get-GitHubRepository -Owner 'PSModule' -Repo 'GitHub' + { Get-GitHubUserCard -Username 'MariusStorhaug' -SubjectType repository -SubjectID $repo.id } | Should -Not -Throw + } + } } Describe 'As GitHub Actions' { @@ -700,6 +736,15 @@ Describe 'As GitHub Actions' { { Get-GitHubMarkdownRaw -Text 'Hello, World!' } | Should -Not -Throw } } + Context 'User' { + It 'Can be called with Username parameter' { + { Get-GitHubUser -Username 'Octocat' } | Should -Not -Throw + } + It 'Can be called with no parameters' { + $repo = Get-GitHubRepository -Owner 'PSModule' -Repo 'GitHub' + { Get-GitHubUserCard -Username 'MariusStorhaug' -SubjectType repository -SubjectID $repo.id } | Should -Not -Throw + } + } } Describe 'As a GitHub App - Enterprise' { @@ -709,6 +754,15 @@ Describe 'As a GitHub App - Enterprise' { AfterAll { Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount } + Context 'User' { + It 'Can be called with Username parameter' { + { Get-GitHubUser -Username 'Octocat' } | Should -Not -Throw + } + It 'Can be called with no parameters' { + $repo = Get-GitHubRepository -Owner 'PSModule' -Repo 'GitHub' + { Get-GitHubUserCard -Username 'MariusStorhaug' -SubjectType repository -SubjectID $repo.id } | Should -Not -Throw + } + } } Describe 'As a GitHub App - Organization' { @@ -773,4 +827,13 @@ Describe 'As a GitHub App - Organization' { } | Should -Not -Throw } } + Context 'User' { + It 'Can be called with Username parameter' { + { Get-GitHubUser -Username 'Octocat' } | Should -Not -Throw + } + It 'Can be called with no parameters' { + $repo = Get-GitHubRepository -Owner 'PSModule' -Repo 'GitHub' + { Get-GitHubUserCard -Username 'MariusStorhaug' -SubjectType repository -SubjectID $repo.id } | Should -Not -Throw + } + } } From 62c598e984f58a10be9263940cd58223b557401b Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 24 Dec 2024 14:37:15 +0100 Subject: [PATCH 02/16] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Remove=20placeh?= =?UTF-8?q?older=20comments=20for=20future=20tests=20in=20Get-GitHubUser?= =?UTF-8?q?=20and=20Get-GitHubUserCard=20functions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/functions/public/Users/Get-GitHubUser.ps1 | 1 - src/functions/public/Users/Get-GitHubUserCard.ps1 | 1 - 2 files changed, 2 deletions(-) diff --git a/src/functions/public/Users/Get-GitHubUser.ps1 b/src/functions/public/Users/Get-GitHubUser.ps1 index b912256e4..6ce36be14 100644 --- a/src/functions/public/Users/Get-GitHubUser.ps1 +++ b/src/functions/public/Users/Get-GitHubUser.ps1 @@ -26,7 +26,6 @@ .NOTES [Get the authenticated user](https://docs.github.com/rest/users/users) #> - #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([pscustomobject])] [Diagnostics.CodeAnalysis.SuppressMessageAttribute( 'PSReviewUnusedParameter', diff --git a/src/functions/public/Users/Get-GitHubUserCard.ps1 b/src/functions/public/Users/Get-GitHubUserCard.ps1 index 4c0ca1e12..f42114014 100644 --- a/src/functions/public/Users/Get-GitHubUserCard.ps1 +++ b/src/functions/public/Users/Get-GitHubUserCard.ps1 @@ -22,7 +22,6 @@ .NOTES [Get contextual information for a user](https://docs.github.com/rest/users/users#get-contextual-information-for-a-user) #> - #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([pscustomobject])] [CmdletBinding()] param( From aba701bf39ae43d596d9c3cdf592aaac19f784f6 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 24 Dec 2024 14:48:27 +0100 Subject: [PATCH 03/16] =?UTF-8?q?=F0=9F=A7=AA=20[Tests]:=20Add=20test=20fo?= =?UTF-8?q?r=20user=20configuration=20settings=20in=20Set-GitHubUser=20fun?= =?UTF-8?q?ction?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/functions/public/Users/Set-GitHubUser.ps1 | 1 - tests/GitHub.Tests.ps1 | 33 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/functions/public/Users/Set-GitHubUser.ps1 b/src/functions/public/Users/Set-GitHubUser.ps1 index e12e21700..b7c23432e 100644 --- a/src/functions/public/Users/Set-GitHubUser.ps1 +++ b/src/functions/public/Users/Set-GitHubUser.ps1 @@ -26,7 +26,6 @@ .NOTES [Update the authenticated user](https://docs.github.com/rest/users/users#update-the-authenticated-user) #> - #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([void])] [Alias('Update-GitHubUser')] [CmdletBinding(SupportsShouldProcess)] diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index e48309755..20cd5ab8e 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -389,6 +389,39 @@ Describe 'As a user - Fine-grained PAT token - user account access' { $repo = Get-GitHubRepository -Owner 'PSModule' -Repo 'GitHub' { Get-GitHubUserCard -Username 'MariusStorhaug' -SubjectType repository -SubjectID $repo.id } | Should -Not -Throw } + It 'Can set configuration on a user' { + $user = Get-GitHubUser + $params = @{ + Name = 'Octocat' + Email = 'psmodule@psmodule.io' + Blog = 'https://marius-storhaug.com' + TwitterUsername = 'MariusStorhaug123' + Company = 'PSModule' + Location = 'USA' + Hireable = $true + Bio = 'I love programming' + } + { Set-GitHubUser @params } | Should -Not -Throw + (Get-GitHubUser).Name | Should -Be 'Octocat' + (Get-GitHubUser).Email | Should -Be 'psmodule@psmodule.io' + (Get-GitHubUser).Blog | Should -Be 'https://marius-storhaug.com' + (Get-GitHubUser).TwitterUsername | Should -Be 'MariusStorhaug123' + (Get-GitHubUser).Company | Should -Be 'PSModule' + (Get-GitHubUser).Location | Should -Be 'USA' + (Get-GitHubUser).Hireable | Should -Be $true + (Get-GitHubUser).Bio | Should -Be 'I love programming' + $user = @{ + Name = $user.Name + Email = $user.Email + Blog = $user.Blog + TwitterUsername = $user.TwitterUsername + Company = $user.Company + Location = $user.Location + Hireable = $user.Hireable + Bio = $user.Bio + } + Set-GitHubUser @user + } } } From 76e8d3b1039e9b8fcf73b5350d529bb6727ada10 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Wed, 25 Dec 2024 01:27:14 +0100 Subject: [PATCH 04/16] Update tests --- tests/GitHub.Tests.ps1 | 266 +++++++++++++++++++---------------------- 1 file changed, 122 insertions(+), 144 deletions(-) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index 20cd5ab8e..4402dac05 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -12,25 +12,25 @@ BeforeAll { Describe 'GitHub' { Context 'Config' { - It 'Get-GitHubConfig - Can get the configuration' { + It 'Get-GitHubConfig - Gets the module configuration' { $config = Get-GitHubConfig Write-Verbose ($config | Format-Table | Out-String) -Verbose $config | Should -Not -BeNullOrEmpty } - It 'Get-GitHubConfig - Can get the configuration by name' { + It 'Get-GitHubConfig - Gets a configuration item by name' { $config = Get-GitHubConfig -Name 'HostName' Write-Verbose ($config | Format-Table | Out-String) -Verbose $config | Should -Not -BeNullOrEmpty } - It 'Set-GitHubConfig - Can set the configuration' { + It 'Set-GitHubConfig - Sets a configuration item' { Set-GitHubConfig -Name 'HostName' -Value 'msx.ghe.com' Get-GitHubConfig -Name 'HostName' | Should -Be 'msx.ghe.com' } - It 'Remove-GetGitHubConfig - Can remove the configuration' { + It 'Remove-GitHubConfig - Removes a configuration item' { Remove-GitHubConfig -Name 'HostName' Get-GitHubConfig -Name 'HostName' | Should -BeNullOrEmpty } - It 'Reset-GitHubConfig - Can reset the configuration' { + It 'Reset-GitHubConfig - Resets the module configuration' { Set-GitHubConfig -Name HostName -Value 'msx.ghe.com' Get-GitHubConfig -Name HostName | Should -Be 'msx.ghe.com' Reset-GitHubConfig @@ -38,39 +38,38 @@ Describe 'GitHub' { } } Context 'Auth' { - It 'Can connect and disconnect without parameters in GitHubActions' { + It 'Connect-GitHubAccount - Connects GitHub Actions without parameters' { { Connect-GitHubAccount } | Should -Not -Throw - { Disconnect-GitHubAccount } | Should -Not -Throw } - It 'Can connect and disconnect - a second time' { - Connect-GitHubAccount - Write-Verbose (Get-GitHubContext | Out-String) -Verbose - Write-Verbose (Get-GitHubConfig | Out-String) -Verbose - Connect-GitHubAccount - Write-Verbose (Get-GitHubContext | Out-String) -Verbose - Write-Verbose (Get-GitHubConfig | Out-String) -Verbose + It 'Disconnect-GitHubAccount - Disconnects GitHub Actions' { { Disconnect-GitHubAccount } | Should -Not -Throw } - It 'Can pass the context to the pipeline' { + It 'Connect-GitHubAccount - Passes the context to the pipeline' { $context = Connect-GitHubAccount -PassThru Write-Verbose (Get-GitHubContext | Out-String) -Verbose $context | Should -Not -BeNullOrEmpty + } + It 'Disconnect-GitHubAccount - Disconnects the context from the pipeline' { { $context | Disconnect-GitHubAccount } | Should -Not -Throw } - It 'Can connect multiple sessions, GITHUB_TOKEN + classic PAT token' { + It 'Connect-GitHubAccount - Connects GitHub Actions even if called multiple times' { + { Connect-GitHubAccount } | Should -Not -Throw + { Connect-GitHubAccount } | Should -Not -Throw + } + It 'Connect-GitHubAccount - Connects multiple contexts, GitHub Actions and a user via classic PAT token' { + { Connect-GitHubAccount } | Should -Not -Throw { Connect-GitHubAccount -Token $env:TEST_USER_PAT } | Should -Not -Throw { Connect-GitHubAccount -Token $env:TEST_USER_PAT } | Should -Not -Throw - { Connect-GitHubAccount } | Should -Not -Throw # Logs on with GitHub Actions' token (Get-GitHubContext -ListAvailable).Count | Should -Be 2 Get-GitHubConfig -Name 'DefaultContext' | Should -Be 'github.com/github-actions/Organization/PSModule' Write-Verbose (Get-GitHubContext | Out-String) -Verbose } - It 'Can reconfigure an existing context to be fine-grained PAT token' { + It 'Connect-GitHubAccount - Reconfigures an existing user context to be a fine-grained PAT token' { { Connect-GitHubAccount -Token $env:TEST_USER_USER_FG_PAT } | Should -Not -Throw (Get-GitHubContext -ListAvailable).Count | Should -Be 2 Write-Verbose (Get-GitHubContext -ListAvailable | Out-String) -Verbose } - It 'Can be called with a GitHub App' { + It 'Connect-GitHubAccount - Connects a GitHub App from an organization' { $params = @{ ClientID = $env:TEST_APP_ORG_CLIENT_ID PrivateKey = $env:TEST_APP_ORG_PRIVATE_KEY @@ -79,12 +78,18 @@ Describe 'GitHub' { $contexts = Get-GitHubContextInfo -Verbose:$false Write-Verbose ($contexts | Out-String) -Verbose ($contexts).Count | Should -Be 3 + } + It 'Connect-GitHubAccount - Connects all of a (org) GitHub Apps installations' { + $params = @{ + ClientID = $env:TEST_APP_ORG_CLIENT_ID + PrivateKey = $env:TEST_APP_ORG_PRIVATE_KEY + } { Connect-GitHubAccount @params -AutoloadInstallations } | Should -Not -Throw $contexts = Get-GitHubContextInfo -Verbose:$false Write-Verbose ($contexts | Out-String) -Verbose ($contexts).Count | Should -Be 5 } - It 'Can be called with a GitHub App and autoload installations' { + It 'Connect-GitHubAccount - Connects a GitHub App from an enterprise' { $params = @{ ClientID = $env:TEST_APP_ENT_CLIENT_ID PrivateKey = $env:TEST_APP_ENT_PRIVATE_KEY @@ -93,158 +98,129 @@ Describe 'GitHub' { $contexts = Get-GitHubContextInfo -Verbose:$false Write-Verbose ($contexts | Out-String) -Verbose ($contexts).Count | Should -Be 6 + } + It 'Connect-GitHubAccount - Connects all of a (ent) GitHub Apps installations' { + $params = @{ + ClientID = $env:TEST_APP_ENT_CLIENT_ID + PrivateKey = $env:TEST_APP_ENT_PRIVATE_KEY + } { Connect-GitHubAccount @params -AutoloadInstallations } | Should -Not -Throw $contexts = Get-GitHubContextInfo -Verbose:$false Write-Verbose ($contexts | Out-String) -Verbose ($contexts).Count | Should -Be 9 } - It 'Can disconnect a specific context' { + It 'Disconnect-GitHubAccount - Disconnects a specific context' { { Disconnect-GitHubAccount -Context 'github.com/psmodule-enterprise-app/Organization/PSModule' -Silent } | Should -Not -Throw $contexts = Get-GitHubContextInfo -Name 'github.com/psmodule-enterprise-app/*' -Verbose:$false Write-Verbose ($contexts | Out-String) -Verbose ($contexts).Count | Should -Be 2 - Connect-GitHubAccount -ClientID $env:TEST_APP_ORG_CLIENT_ID -PrivateKey $env:TEST_APP_ORG_PRIVATE_KEY -AutoloadInstallations - $contexts = Get-GitHubContext -ListAvailable -Verbose:$false - Write-Verbose ($contexts | Out-String) -Verbose - ($contexts).Count | Should -Be 8 - } - It 'Can get the authenticated GitHubApp' { - $app = Get-GitHubApp - Write-Verbose ($app | Format-Table | Out-String) -Verbose - $app | Should -Not -BeNullOrEmpty } - It 'Can connect to a GitHub App Installation' { - $appContext = Connect-GitHubApp -Organization 'PSModule' -PassThru - Write-Verbose ($appContext | Out-String) -Verbose - $appContext | Should -Not -BeNullOrEmpty - { $appContext | Disconnect-GitHub } | Should -Not -Throw - } - It 'Can connect to all GitHub App Installations' { - { Connect-GitHubApp } | Should -Not -Throw - Write-Verbose 'Default context:' -Verbose - Write-Verbose (Get-GitHubContext | Out-String) -Verbose - Write-Verbose 'All contexts:' -Verbose - Write-Verbose (Get-GitHubContext -ListAvailable | Out-String) -Verbose - } - It 'Can swap context to another' { + It 'Set-GitHubDefaultContext - Can swap context to another' { { Set-GitHubDefaultContext -Context 'github.com/github-actions/Organization/PSModule' } | Should -Not -Throw Get-GitHubConfig -Name 'DefaultContext' | Should -Be 'github.com/github-actions/Organization/PSModule' } - It 'Get-GitHubViewer can be called' { - Get-GitHubViewer | Should -Not -BeNullOrEmpty - } - It 'Get-GitHubConfig gets the DefaultContext' { - Write-Verbose (Get-GitHubConfig -Name 'DefaultContext') -Verbose - { Get-GitHubConfig -Name 'DefaultContext' } | Should -Not -Throw - } - It 'Can be called without a parameter' { - $config = Get-GitHubConfig - Write-Verbose ($config | Format-Table | Out-String) -Verbose - { Get-GitHubConfig } | Should -Not -Throw - $config.ID | Should -Be 'PSModule.GitHub' - } } Context 'Status' -ForEach @('public', 'eu') { - It 'Can be called with no parameters' { + It 'Get-GitHubScheduledMaintenance - Gets scheduled maintenance for <_>' { { Get-GitHubScheduledMaintenance -Stamp $_ } | Should -Not -Throw } - It 'Can be called with Active parameter' { + It 'Get-GitHubScheduledMaintenance - Gets active maintenance for <_>' { { Get-GitHubScheduledMaintenance -Stamp $_ -Active } | Should -Not -Throw } - It 'Can be called with Upcoming parameter' { + It 'Get-GitHubScheduledMaintenance - Gets upcoming maintenance for <_>' { { Get-GitHubScheduledMaintenance -Stamp $_ -Upcoming } | Should -Not -Throw } - It 'Can be called with no parameters' { + It 'Get-GitHubStatus - Gets all status for <_>' { { Get-GitHubStatus -Stamp $_ } | Should -Not -Throw } - It 'Can be called with Summary parameter' { + It 'Get-GitHubStatus - Gets summary status for <_>' { { Get-GitHubStatus -Stamp $_ -Summary } | Should -Not -Throw } - It 'Can be called with no parameters' { + It 'Get-GitHubStatusComponent - Gets the status of GitHub components for <_>' { { Get-GitHubStatusComponent -Stamp $_ } | Should -Not -Throw } - It 'Can be called with no parameters' { + It 'Get-GitHubStatusIncident - Gets the status of all GitHub incidents for <_>' { { Get-GitHubStatusIncident -Stamp $_ } | Should -Not -Throw } - It 'Can be called with Unresolved parameter' { + It 'Get-GitHubStatusIncident - Gets the status of unresolved GitHub incidents for <_>' { { Get-GitHubStatusIncident -Stamp $_ -Unresolved } | Should -Not -Throw } } Context 'Commands' { - It "Start-GitHubLogGroup 'MyGroup' should not throw" { + It 'Start-GitHubLogGroup - Should not throw' { { Start-GitHubLogGroup 'MyGroup' } | Should -Not -Throw } - It 'Stop-LogGroup should not throw' { + It 'Stop-LogGroup - Should not throw' { { Stop-GitHubLogGroup } | Should -Not -Throw } - It "Set-GitHubLogGroup 'MyGroup' should not throw" { + It 'Set-GitHubLogGroup - Should not throw' { { Set-GitHubLogGroup -Name 'MyGroup' -ScriptBlock { Get-ChildItem env: | Select-Object Name, Value | Format-Table -AutoSize } } | Should -Not -Throw } - It "LogGroup 'MyGroup' should not throw" { + It 'LogGroup - Should not throw' { { LogGroup 'MyGroup' { Get-ChildItem env: | Select-Object Name, Value | Format-Table -AutoSize } } | Should -Not -Throw } - It 'Add-GitHubMask should not throw' { + It 'Add-GitHubMask - Should not throw' { { Add-GitHubMask -Value 'taskmaster' } | Should -Not -Throw } - It 'Add-GitHubSystemPath should not throw' { + It 'Add-GitHubSystemPath - Should not throw' { { Add-GitHubSystemPath -Path $pwd.ToString() } | Should -Not -Throw Get-Content $env:GITHUB_PATH -Raw | Should -BeLike "*$($pwd.ToString())*" } - It 'Disable-GitHubCommand should not throw' { + It 'Disable-GitHubCommand - Should not throw' { { Disable-GitHubCommand -String 'MyString' } | Should -Not -Throw } - It 'Enable-GitHubCommand should not throw' { + It 'Enable-GitHubCommand - Should not throw' { { Enable-GitHubCommand -String 'MyString' } | Should -Not -Throw } - It 'Set-GitHubNoCommandGroup should not throw' { + It 'Set-GitHubNoCommandGroup - Should not throw' { { Set-GitHubNoCommandGroup { Write-Output 'Hello, World!' } } | Should -Not -Throw } - It 'Set-GitHubOutput should not throw' { + It 'Set-GitHubOutput - Should not throw' { { Set-GitHubOutput -Name 'MyName' -Value 'MyValue' } | Should -Not -Throw } - It 'Get-GitHubOutput should not throw' { + It 'Get-GitHubOutput - Should not throw' { { Get-GitHubOutput } | Should -Not -Throw } - It 'Set-GitHubEnvironmentVariable should not throw' { + It 'Set-GitHubEnvironmentVariable - Should not throw' { { Set-GitHubEnvironmentVariable -Name 'MyName' -Value 'MyValue' } | Should -Not -Throw Get-Content $env:GITHUB_ENV -Raw | Should -BeLike '*MyName*MyValue*' } - It 'Set-GitHubStepSummary should not throw' { + It 'Set-GitHubStepSummary - Should not throw' { { Set-GitHubStepSummary -Summary 'MySummary' } | Should -Not -Throw } - It 'Write-GitHub* should not throw' { + It 'Write-GitHub* - Should not throw' { { Write-GitHubDebug 'Debug' } | Should -Not -Throw { Write-GitHubError 'Error' } | Should -Not -Throw { Write-GitHubNotice 'Notice' } | Should -Not -Throw @@ -252,7 +228,7 @@ Describe 'GitHub' { } } Context 'Disconnect' { - It 'Can disconnect without parameters' { + It 'Disconnect-GitHubAccount - Can disconnect all context through the pipeline' { { Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount } | Should -Not -Throw Get-GitHubContext -ListAvailable | Should -HaveCount 0 } @@ -266,17 +242,21 @@ Describe 'As a user - Fine-grained PAT token - user account access' { AfterAll { Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount } + Context 'Auth' { + It 'Get-GitHubViewer - Gets the logged in context' { + Get-GitHubViewer | Should -Not -BeNullOrEmpty + } + } Context 'API' { - It 'Can be called directly to get ratelimits' { + It 'Invoke-GitHubAPI - Gets the rate limits directly' { { $rateLimit = Invoke-GitHubAPI -ApiEndpoint '/rate_limit' Write-Verbose ($rateLimit | Format-Table | Out-String) -Verbose } | Should -Not -Throw - } } Context 'GraphQL' { - It 'Can be called directly to get viewer' { + It 'Invoke-GitHubGraphQLQuery - Gets the viewer directly' { { $viewer = Invoke-GitHubGraphQLQuery -Query 'query { viewer { login } }' Write-Verbose ($viewer | Format-Table | Out-String) -Verbose @@ -284,112 +264,103 @@ Describe 'As a user - Fine-grained PAT token - user account access' { } } Context 'Meta' { - It 'Get-GitHubRoot' { + It 'Get-GitHubRoot - Gets the GitHub API Root' { $root = Get-GitHubRoot Write-Verbose ($root | Format-Table | Out-String) -Verbose $root | Should -Not -BeNullOrEmpty } - It 'Get-GitHubApiVersion' { + It 'Get-GitHubApiVersion - Gets all API versions' { $apiVersion = Get-GitHubApiVersion Write-Verbose ($apiVersion | Format-Table | Out-String) -Verbose $apiVersion | Should -Not -BeNullOrEmpty } - It 'Get-GitHubMeta' { + It 'Get-GitHubMeta - Gets GitHub meta information' { $meta = Get-GitHubMeta Write-Verbose ($meta | Format-Table | Out-String) -Verbose $meta | Should -Not -BeNullOrEmpty } - It 'Get-GitHubOctocat' { + It 'Get-GitHubOctocat - Gets the Octocat' { $octocat = Get-GitHubOctocat Write-Verbose ($octocat | Format-Table | Out-String) -Verbose $octocat | Should -Not -BeNullOrEmpty } - It 'Get-GitHubZen' { + It 'Get-GitHubZen - Gets the Zen of GitHub' { $zen = Get-GitHubZen Write-Verbose ($zen | Format-Table | Out-String) -Verbose $zen | Should -Not -BeNullOrEmpty } } Context 'Rate-Limit' { - It 'Can be called with no parameters' { + It 'Get-GitHubRateLimit - Gets the rate limit status for the authenticated user' { { Get-GitHubRateLimit } | Should -Not -Throw } } Context 'License' { - It 'Can be called with no parameters' { + It 'Get-GitHubLicense - Gets a list of all popular license templates' { { Get-GitHubLicense } | Should -Not -Throw } - It 'Can be called with Name parameter' { + It 'Get-GitHubLicense - Gets a spesific license' { { Get-GitHubLicense -Name 'mit' } | Should -Not -Throw } - It 'Can be called with Repository parameter' { + It 'Get-GitHubLicense - Gets a license from a repository' { { Get-GitHubLicense -Owner 'PSModule' -Repo 'GitHub' } | Should -Not -Throw } } Context 'Emoji' { - It 'Can be called with no parameters' { + It 'Get-GitHubEmoji - Gets a list of all emojis' { { Get-GitHubEmoji } | Should -Not -Throw } - It 'Can download the emojis' { + It 'Get-GitHubEmoji - Downloads all emojis' { { Get-GitHubEmoji -Destination $Home } | Should -Not -Throw } } Context 'Repository' { - Context 'Parameter Set: MyRepos_Type' { - It 'Can be called with no parameters' { - { Get-GitHubRepository } | Should -Not -Throw - } - - It 'Can be called with Type parameter' { - { Get-GitHubRepository -Type 'public' } | Should -Not -Throw - } + It "Get-GitHubRepository - Gets the authenticated user's repositories" { + { Get-GitHubRepository } | Should -Not -Throw } - Context 'Parameter Set: MyRepos_Aff-Vis' { - It 'Can be called with Visibility and Affiliation parameters' { - { Get-GitHubRepository -Visibility 'public' -Affiliation 'owner' } | Should -Not -Throw - } + It "Get-GitHubRepository - Gets the authenticated user's public repositories" { + { Get-GitHubRepository -Type 'public' } | Should -Not -Throw } - It 'Can be called with Owner and Repo parameters' { + It 'Get-GitHubRepository - Gets the public repos where the authenticated user is owner' { + { Get-GitHubRepository -Visibility 'public' -Affiliation 'owner' } | Should -Not -Throw + } + It 'Get-GitHubRepository - Gets a specific repository' { { Get-GitHubRepository -Owner 'PSModule' -Repo 'GitHub' } | Should -Not -Throw } - It 'Can be called with Owner parameter' { + It 'Get-GitHubRepository - Gets all repositories from a organization' { { Get-GitHubRepository -Owner 'PSModule' } | Should -Not -Throw } - It 'Can be called with Username parameter' { + It 'Get-GitHubRepository - Gets all repositories from a user' { { Get-GitHubRepository -Username 'MariusStorhaug' } | Should -Not -Throw } } Context 'GitIgnore' { - It 'Can be called with no parameters' { + It 'Get-GitHubGitignore - Gets a list of all gitignore templates names' { { Get-GitHubGitignore } | Should -Not -Throw } - It 'Can be called with Name parameter' { + It 'Get-GitHubGitignore - Gets a gitignore template' { { Get-GitHubGitignore -Name 'VisualStudio' } | Should -Not -Throw } } Context 'Markdown' { - It 'Can be called with Text parameter' { + It 'Get-GitHubMarkdown - Gets the rendered markdown for provided text' { { Get-GitHubMarkdown -Text 'Hello, World!' } | Should -Not -Throw } - It 'Can be called with Text parameter and GitHub Format Mardown' { + It 'Get-GitHubMarkdown - Gets the rendered markdown for provided text using GitHub Formated Markdown' { { Get-GitHubMarkdown -Text 'Hello, World!' -Mode gfm } | Should -Not -Throw } - It 'Raw - Can be called with Text parameter' { + It 'Get-GitHubMarkdownRaw - Gets the raw rendered markdown for provided text' { { Get-GitHubMarkdownRaw -Text 'Hello, World!' } | Should -Not -Throw } } Context 'User' { - It 'Can be called with no parameters' { + It 'Get-GitHubUser - Gets the authenticated user' { { Get-GitHubUser } | Should -Not -Throw } - It 'Can be called with Username parameter' { + It 'Get-GitHubUser - Get the specified user' { { Get-GitHubUser -Username 'Octocat' } | Should -Not -Throw } - It 'Can be called with no parameters' { - $repo = Get-GitHubRepository -Owner 'PSModule' -Repo 'GitHub' - { Get-GitHubUserCard -Username 'MariusStorhaug' -SubjectType repository -SubjectID $repo.id } | Should -Not -Throw - } - It 'Can set configuration on a user' { + It 'Get-GitHubUser - Can set configuration on a user' { $user = Get-GitHubUser $params = @{ Name = 'Octocat' @@ -402,14 +373,15 @@ Describe 'As a user - Fine-grained PAT token - user account access' { Bio = 'I love programming' } { Set-GitHubUser @params } | Should -Not -Throw - (Get-GitHubUser).Name | Should -Be 'Octocat' - (Get-GitHubUser).Email | Should -Be 'psmodule@psmodule.io' - (Get-GitHubUser).Blog | Should -Be 'https://marius-storhaug.com' - (Get-GitHubUser).TwitterUsername | Should -Be 'MariusStorhaug123' - (Get-GitHubUser).Company | Should -Be 'PSModule' - (Get-GitHubUser).Location | Should -Be 'USA' - (Get-GitHubUser).Hireable | Should -Be $true - (Get-GitHubUser).Bio | Should -Be 'I love programming' + $tmpUser = Get-GitHubUser + $tmpUser.Name | Should -Be 'Octocat' + $tmpUser.Email | Should -Be 'psmodule@psmodule.io' + $tmpUser.Blog | Should -Be 'https://marius-storhaug.com' + $tmpUser.TwitterUsername | Should -Be 'MariusStorhaug123' + $tmpUser.Company | Should -Be 'PSModule' + $tmpUser.Location | Should -Be 'USA' + $tmpUser.Hireable | Should -Be $true + $tmpUser.Bio | Should -Be 'I love programming' $user = @{ Name = $user.Name Email = $user.Email @@ -432,6 +404,11 @@ Describe 'As a user - Fine-grained PAT token - organization account access' { AfterAll { Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount } + Context 'Auth' { + It 'Get-GitHubViewer - Gets the logged in context' { + Get-GitHubViewer | Should -Not -BeNullOrEmpty + } + } Context 'API' { It 'Can be called directly to get ratelimits' { { @@ -549,10 +526,6 @@ Describe 'As a user - Fine-grained PAT token - organization account access' { It 'Can be called with Username parameter' { { Get-GitHubUser -Username 'Octocat' } | Should -Not -Throw } - It 'Can be called with no parameters' { - $repo = Get-GitHubRepository -Owner 'PSModule' -Repo 'GitHub' - { Get-GitHubUserCard -Username 'MariusStorhaug' -SubjectType repository -SubjectID $repo.id } | Should -Not -Throw - } } } @@ -563,6 +536,11 @@ Describe 'As a user - Classic PAT token' { AfterAll { Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount } + Context 'Auth' { + It 'Get-GitHubViewer - Gets the logged in context' { + Get-GitHubViewer | Should -Not -BeNullOrEmpty + } + } Context 'API' { It 'Can be called directly to get ratelimits' { { @@ -671,6 +649,11 @@ Describe 'As GitHub Actions' { AfterAll { Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount } + Context 'Auth' { + It 'Get-GitHubViewer - Gets the logged in context' { + Get-GitHubViewer | Should -Not -BeNullOrEmpty + } + } Context 'API' { It 'Can be called directly to get ratelimits' { { @@ -773,10 +756,6 @@ Describe 'As GitHub Actions' { It 'Can be called with Username parameter' { { Get-GitHubUser -Username 'Octocat' } | Should -Not -Throw } - It 'Can be called with no parameters' { - $repo = Get-GitHubRepository -Owner 'PSModule' -Repo 'GitHub' - { Get-GitHubUserCard -Username 'MariusStorhaug' -SubjectType repository -SubjectID $repo.id } | Should -Not -Throw - } } } @@ -791,9 +770,12 @@ Describe 'As a GitHub App - Enterprise' { It 'Can be called with Username parameter' { { Get-GitHubUser -Username 'Octocat' } | Should -Not -Throw } - It 'Can be called with no parameters' { - $repo = Get-GitHubRepository -Owner 'PSModule' -Repo 'GitHub' - { Get-GitHubUserCard -Username 'MariusStorhaug' -SubjectType repository -SubjectID $repo.id } | Should -Not -Throw + } + Context 'App' { + It 'Can get the authenticated GitHubApp' { + $app = Get-GitHubApp + Write-Verbose ($app | Format-Table | Out-String) -Verbose + $app | Should -Not -BeNullOrEmpty } } } @@ -864,9 +846,5 @@ Describe 'As a GitHub App - Organization' { It 'Can be called with Username parameter' { { Get-GitHubUser -Username 'Octocat' } | Should -Not -Throw } - It 'Can be called with no parameters' { - $repo = Get-GitHubRepository -Owner 'PSModule' -Repo 'GitHub' - { Get-GitHubUserCard -Username 'MariusStorhaug' -SubjectType repository -SubjectID $repo.id } | Should -Not -Throw - } } } From aecefb837ad8cee4809787948130d5fef38c20af Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Wed, 25 Dec 2024 09:51:03 +0100 Subject: [PATCH 05/16] Refactor user retrieval functions for improved clarity and maintainability --- tests/GitHub.Tests.ps1 | 257 ++++++++++++++++++++++++++++------------- 1 file changed, 176 insertions(+), 81 deletions(-) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index 4402dac05..ffecc8831 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -410,7 +410,7 @@ Describe 'As a user - Fine-grained PAT token - organization account access' { } } Context 'API' { - It 'Can be called directly to get ratelimits' { + It 'Invoke-GitHubAPI - Gets the rate limits directly' { { $rateLimit = Invoke-GitHubAPI -ApiEndpoint '/rate_limit' Write-Verbose ($rateLimit | Format-Table | Out-String) -Verbose @@ -418,7 +418,7 @@ Describe 'As a user - Fine-grained PAT token - organization account access' { } } Context 'GraphQL' { - It 'Can be called directly to get viewer' { + It 'Invoke-GitHubGraphQLQuery - Gets the viewer directly' { { $viewer = Invoke-GitHubGraphQLQuery -Query 'query { viewer { login } }' Write-Verbose ($viewer | Format-Table | Out-String) -Verbose @@ -426,106 +426,136 @@ Describe 'As a user - Fine-grained PAT token - organization account access' { } } Context 'Meta' { - It 'Get-GitHubRoot' { + It 'Get-GitHubRoot - Gets the GitHub API Root' { $root = Get-GitHubRoot Write-Verbose ($root | Format-Table | Out-String) -Verbose $root | Should -Not -BeNullOrEmpty } - It 'Get-GitHubApiVersion' { + It 'Get-GitHubApiVersion - Gets all API versions' { $apiVersion = Get-GitHubApiVersion Write-Verbose ($apiVersion | Format-Table | Out-String) -Verbose $apiVersion | Should -Not -BeNullOrEmpty } - It 'Get-GitHubMeta' { + It 'Get-GitHubMeta - Gets GitHub meta information' { $meta = Get-GitHubMeta Write-Verbose ($meta | Format-Table | Out-String) -Verbose $meta | Should -Not -BeNullOrEmpty } - It 'Get-GitHubOctocat' { + It 'Get-GitHubOctocat - Gets the Octocat' { $octocat = Get-GitHubOctocat Write-Verbose ($octocat | Format-Table | Out-String) -Verbose $octocat | Should -Not -BeNullOrEmpty } - It 'Get-GitHubZen' { + It 'Get-GitHubZen - Gets the Zen of GitHub' { $zen = Get-GitHubZen Write-Verbose ($zen | Format-Table | Out-String) -Verbose $zen | Should -Not -BeNullOrEmpty } } Context 'Rate-Limit' { - It 'Can be called with no parameters' { + It 'Get-GitHubRateLimit - Gets the rate limit status for the authenticated user' { { Get-GitHubRateLimit } | Should -Not -Throw } } Context 'License' { - It 'Can be called with no parameters' { + It 'Get-GitHubLicense - Gets a list of all popular license templates' { { Get-GitHubLicense } | Should -Not -Throw } - It 'Can be called with Name parameter' { + It 'Get-GitHubLicense - Gets a spesific license' { { Get-GitHubLicense -Name 'mit' } | Should -Not -Throw } - It 'Can be called with Repository parameter' { + It 'Get-GitHubLicense - Gets a license from a repository' { { Get-GitHubLicense -Owner 'PSModule' -Repo 'GitHub' } | Should -Not -Throw } } Context 'Emoji' { - It 'Can be called with no parameters' { + It 'Get-GitHubEmoji - Gets a list of all emojis' { { Get-GitHubEmoji } | Should -Not -Throw } - It 'Can be download the emojis' { + It 'Get-GitHubEmoji - Downloads all emojis' { { Get-GitHubEmoji -Destination $Home } | Should -Not -Throw } } Context 'Repository' { - Context 'Parameter Set: MyRepos_Type' { - It 'Can be called with no parameters' { - { Get-GitHubRepository } | Should -Not -Throw - } - It 'Can be called with Type parameter' { - { Get-GitHubRepository -Type 'public' } | Should -Not -Throw - } + It "Get-GitHubRepository - Gets the authenticated user's repositories" { + { Get-GitHubRepository } | Should -Not -Throw } - Context 'Parameter Set: MyRepos_Aff-Vis' { - It 'Can be called with Visibility and Affiliation parameters' { - { Get-GitHubRepository -Visibility 'public' -Affiliation 'owner' } | Should -Not -Throw - } + It "Get-GitHubRepository - Gets the authenticated user's public repositories" { + { Get-GitHubRepository -Type 'public' } | Should -Not -Throw + } + It 'Get-GitHubRepository - Gets the public repos where the authenticated user is owner' { + { Get-GitHubRepository -Visibility 'public' -Affiliation 'owner' } | Should -Not -Throw } - It 'Can be called with Owner and Repo parameters' { + It 'Get-GitHubRepository - Gets a specific repository' { { Get-GitHubRepository -Owner 'PSModule' -Repo 'GitHub' } | Should -Not -Throw } - It 'Can be called with Owner parameter' { + It 'Get-GitHubRepository - Gets all repositories from a organization' { { Get-GitHubRepository -Owner 'PSModule' } | Should -Not -Throw } - It 'Can be called with Username parameter' { + It 'Get-GitHubRepository - Gets all repositories from a user' { { Get-GitHubRepository -Username 'MariusStorhaug' } | Should -Not -Throw } } Context 'GitIgnore' { - It 'Can be called with no parameters' { + It 'Get-GitHubGitignore - Gets a list of all gitignore templates names' { { Get-GitHubGitignore } | Should -Not -Throw } - It 'Can be called with Name parameter' { + It 'Get-GitHubGitignore - Gets a gitignore template' { { Get-GitHubGitignore -Name 'VisualStudio' } | Should -Not -Throw } } Context 'Markdown' { - It 'Can be called with Text parameter' { - { Get-GitHubMarkdown -Text 'Hello, **World**' } | Should -Not -Throw + It 'Get-GitHubMarkdown - Gets the rendered markdown for provided text' { + { Get-GitHubMarkdown -Text 'Hello, World!' } | Should -Not -Throw } - It 'Can be called with Text parameter and GitHub Format Mardown' { - { Get-GitHubMarkdown -Text 'Hello, **World**' -Mode gfm } | Should -Not -Throw + It 'Get-GitHubMarkdown - Gets the rendered markdown for provided text using GitHub Formated Markdown' { + { Get-GitHubMarkdown -Text 'Hello, World!' -Mode gfm } | Should -Not -Throw } - It 'Raw - Can be called with Text parameter' { - { Get-GitHubMarkdownRaw -Text 'Hello, **World**' } | Should -Not -Throw + It 'Get-GitHubMarkdownRaw - Gets the raw rendered markdown for provided text' { + { Get-GitHubMarkdownRaw -Text 'Hello, World!' } | Should -Not -Throw } } Context 'User' { - It 'Can be called with no parameters' { + It 'Get-GitHubUser - Gets the authenticated user' { { Get-GitHubUser } | Should -Not -Throw } - It 'Can be called with Username parameter' { + It 'Get-GitHubUser - Get the specified user' { { Get-GitHubUser -Username 'Octocat' } | Should -Not -Throw } + It 'Get-GitHubUser - Can set configuration on a user' { + $user = Get-GitHubUser + $params = @{ + Name = 'Octocat' + Email = 'psmodule@psmodule.io' + Blog = 'https://marius-storhaug.com' + TwitterUsername = 'MariusStorhaug123' + Company = 'PSModule' + Location = 'USA' + Hireable = $true + Bio = 'I love programming' + } + { Set-GitHubUser @params } | Should -Not -Throw + $tmpUser = Get-GitHubUser + $tmpUser.Name | Should -Be 'Octocat' + $tmpUser.Email | Should -Be 'psmodule@psmodule.io' + $tmpUser.Blog | Should -Be 'https://marius-storhaug.com' + $tmpUser.TwitterUsername | Should -Be 'MariusStorhaug123' + $tmpUser.Company | Should -Be 'PSModule' + $tmpUser.Location | Should -Be 'USA' + $tmpUser.Hireable | Should -Be $true + $tmpUser.Bio | Should -Be 'I love programming' + $user = @{ + Name = $user.Name + Email = $user.Email + Blog = $user.Blog + TwitterUsername = $user.TwitterUsername + Company = $user.Company + Location = $user.Location + Hireable = $user.Hireable + Bio = $user.Bio + } + Set-GitHubUser @user + } } } @@ -542,16 +572,15 @@ Describe 'As a user - Classic PAT token' { } } Context 'API' { - It 'Can be called directly to get ratelimits' { + It 'Invoke-GitHubAPI - Gets the rate limits directly' { { $rateLimit = Invoke-GitHubAPI -ApiEndpoint '/rate_limit' Write-Verbose ($rateLimit | Format-Table | Out-String) -Verbose } | Should -Not -Throw - } } Context 'GraphQL' { - It 'Can be called directly to get viewer' { + It 'Invoke-GitHubGraphQLQuery - Gets the viewer directly' { { $viewer = Invoke-GitHubGraphQLQuery -Query 'query { viewer { login } }' Write-Verbose ($viewer | Format-Table | Out-String) -Verbose @@ -559,85 +588,115 @@ Describe 'As a user - Classic PAT token' { } } Context 'Meta' { - It 'Get-GitHubRoot' { + It 'Get-GitHubRoot - Gets the GitHub API Root' { $root = Get-GitHubRoot Write-Verbose ($root | Format-Table | Out-String) -Verbose $root | Should -Not -BeNullOrEmpty } - It 'Get-GitHubApiVersion' { + It 'Get-GitHubApiVersion - Gets all API versions' { $apiVersion = Get-GitHubApiVersion Write-Verbose ($apiVersion | Format-Table | Out-String) -Verbose $apiVersion | Should -Not -BeNullOrEmpty } - It 'Get-GitHubMeta' { + It 'Get-GitHubMeta - Gets GitHub meta information' { $meta = Get-GitHubMeta Write-Verbose ($meta | Format-Table | Out-String) -Verbose $meta | Should -Not -BeNullOrEmpty } - It 'Get-GitHubOctocat' { + It 'Get-GitHubOctocat - Gets the Octocat' { $octocat = Get-GitHubOctocat Write-Verbose ($octocat | Format-Table | Out-String) -Verbose $octocat | Should -Not -BeNullOrEmpty } - It 'Get-GitHubZen' { + It 'Get-GitHubZen - Gets the Zen of GitHub' { $zen = Get-GitHubZen Write-Verbose ($zen | Format-Table | Out-String) -Verbose $zen | Should -Not -BeNullOrEmpty } } Context 'Rate-Limit' { - It 'Can be called with no parameters' { + It 'Get-GitHubRateLimit - Gets the rate limit status for the authenticated user' { { Get-GitHubRateLimit } | Should -Not -Throw } } Context 'License' { - It 'Can be called with no parameters' { + It 'Get-GitHubLicense - Gets a list of all popular license templates' { { Get-GitHubLicense } | Should -Not -Throw } - It 'Can be called with Name parameter' { + It 'Get-GitHubLicense - Gets a spesific license' { { Get-GitHubLicense -Name 'mit' } | Should -Not -Throw } - It 'Can be called with Repository parameter' { + It 'Get-GitHubLicense - Gets a license from a repository' { { Get-GitHubLicense -Owner 'PSModule' -Repo 'GitHub' } | Should -Not -Throw } } Context 'Emoji' { - It 'Can be called with no parameters' { + It 'Get-GitHubEmoji - Gets a list of all emojis' { { Get-GitHubEmoji } | Should -Not -Throw } - It 'Can be download the emojis' { + It 'Get-GitHubEmoji - Downloads all emojis' { { Get-GitHubEmoji -Destination $Home } | Should -Not -Throw } } Context 'GitIgnore' { - It 'Can be called with no parameters' { + It 'Get-GitHubGitignore - Gets a list of all gitignore templates names' { { Get-GitHubGitignore } | Should -Not -Throw } - It 'Can be called with Name parameter' { + It 'Get-GitHubGitignore - Gets a gitignore template' { { Get-GitHubGitignore -Name 'VisualStudio' } | Should -Not -Throw } } Context 'Markdown' { - It 'Can be called with Text parameter' { + It 'Get-GitHubMarkdown - Gets the rendered markdown for provided text' { { Get-GitHubMarkdown -Text 'Hello, World!' } | Should -Not -Throw } - It 'Can be called with Text parameter and GitHub Format Mardown' { + It 'Get-GitHubMarkdown - Gets the rendered markdown for provided text using GitHub Formated Markdown' { { Get-GitHubMarkdown -Text 'Hello, World!' -Mode gfm } | Should -Not -Throw } - It 'Raw - Can be called with Text parameter' { + It 'Get-GitHubMarkdownRaw - Gets the raw rendered markdown for provided text' { { Get-GitHubMarkdownRaw -Text 'Hello, World!' } | Should -Not -Throw } } Context 'User' { - It 'Can be called with no parameters' { + It 'Get-GitHubUser - Gets the authenticated user' { { Get-GitHubUser } | Should -Not -Throw } - It 'Can be called with Username parameter' { + It 'Get-GitHubUser - Get the specified user' { { Get-GitHubUser -Username 'Octocat' } | Should -Not -Throw } - It 'Can be called with no parameters' { - $repo = Get-GitHubRepository -Owner 'PSModule' -Repo 'GitHub' - { Get-GitHubUserCard -Username 'MariusStorhaug' -SubjectType repository -SubjectID $repo.id } | Should -Not -Throw + It 'Get-GitHubUser - Can set configuration on a user' { + $user = Get-GitHubUser + $params = @{ + Name = 'Octocat' + Email = 'psmodule@psmodule.io' + Blog = 'https://marius-storhaug.com' + TwitterUsername = 'MariusStorhaug123' + Company = 'PSModule' + Location = 'USA' + Hireable = $true + Bio = 'I love programming' + } + { Set-GitHubUser @params } | Should -Not -Throw + $tmpUser = Get-GitHubUser + $tmpUser.Name | Should -Be 'Octocat' + $tmpUser.Email | Should -Be 'psmodule@psmodule.io' + $tmpUser.Blog | Should -Be 'https://marius-storhaug.com' + $tmpUser.TwitterUsername | Should -Be 'MariusStorhaug123' + $tmpUser.Company | Should -Be 'PSModule' + $tmpUser.Location | Should -Be 'USA' + $tmpUser.Hireable | Should -Be $true + $tmpUser.Bio | Should -Be 'I love programming' + $user = @{ + Name = $user.Name + Email = $user.Email + Blog = $user.Blog + TwitterUsername = $user.TwitterUsername + Company = $user.Company + Location = $user.Location + Hireable = $user.Hireable + Bio = $user.Bio + } + Set-GitHubUser @user } } } @@ -655,16 +714,15 @@ Describe 'As GitHub Actions' { } } Context 'API' { - It 'Can be called directly to get ratelimits' { + It 'Invoke-GitHubAPI - Gets the rate limits directly' { { $rateLimit = Invoke-GitHubAPI -ApiEndpoint '/rate_limit' Write-Verbose ($rateLimit | Format-Table | Out-String) -Verbose } | Should -Not -Throw - } } Context 'GraphQL' { - It 'Can be called directly to get viewer' { + It 'Invoke-GitHubGraphQLQuery - Gets the viewer directly' { { $viewer = Invoke-GitHubGraphQLQuery -Query 'query { viewer { login } }' Write-Verbose ($viewer | Format-Table | Out-String) -Verbose @@ -683,79 +741,116 @@ Describe 'As GitHub Actions' { } } Context 'Meta' { - It 'Get-GitHubRoot' { + It 'Get-GitHubRoot - Gets the GitHub API Root' { $root = Get-GitHubRoot Write-Verbose ($root | Format-Table | Out-String) -Verbose $root | Should -Not -BeNullOrEmpty } - It 'Get-GitHubApiVersion' { + It 'Get-GitHubApiVersion - Gets all API versions' { $apiVersion = Get-GitHubApiVersion Write-Verbose ($apiVersion | Format-Table | Out-String) -Verbose $apiVersion | Should -Not -BeNullOrEmpty } - It 'Get-GitHubMeta' { + It 'Get-GitHubMeta - Gets GitHub meta information' { $meta = Get-GitHubMeta Write-Verbose ($meta | Format-Table | Out-String) -Verbose $meta | Should -Not -BeNullOrEmpty } - It 'Get-GitHubOctocat' { + It 'Get-GitHubOctocat - Gets the Octocat' { $octocat = Get-GitHubOctocat Write-Verbose ($octocat | Format-Table | Out-String) -Verbose $octocat | Should -Not -BeNullOrEmpty } - It 'Get-GitHubZen' { + It 'Get-GitHubZen - Gets the Zen of GitHub' { $zen = Get-GitHubZen Write-Verbose ($zen | Format-Table | Out-String) -Verbose $zen | Should -Not -BeNullOrEmpty } } Context 'Rate-Limit' { - It 'Can be called with no parameters' { + It 'Get-GitHubRateLimit - Gets the rate limit status for the authenticated user' { { Get-GitHubRateLimit } | Should -Not -Throw } } Context 'License' { - It 'Can be called with no parameters' { + It 'Get-GitHubLicense - Gets a list of all popular license templates' { { Get-GitHubLicense } | Should -Not -Throw } - It 'Can be called with Name parameter' { + It 'Get-GitHubLicense - Gets a spesific license' { { Get-GitHubLicense -Name 'mit' } | Should -Not -Throw } - It 'Can be called with Repository parameter' { + It 'Get-GitHubLicense - Gets a license from a repository' { { Get-GitHubLicense -Owner 'PSModule' -Repo 'GitHub' } | Should -Not -Throw } } Context 'Emoji' { - It 'Can be called with no parameters' { + It 'Get-GitHubEmoji - Gets a list of all emojis' { { Get-GitHubEmoji } | Should -Not -Throw } - It 'Can be download the emojis' { + It 'Get-GitHubEmoji - Downloads all emojis' { { Get-GitHubEmoji -Destination $Home } | Should -Not -Throw } } Context 'GitIgnore' { - It 'Can be called with no parameters' { + It 'Get-GitHubGitignore - Gets a list of all gitignore templates names' { { Get-GitHubGitignore } | Should -Not -Throw } - It 'Can be called with Name parameter' { + It 'Get-GitHubGitignore - Gets a gitignore template' { { Get-GitHubGitignore -Name 'VisualStudio' } | Should -Not -Throw } } Context 'Markdown' { - It 'Can be called with Text parameter' { + It 'Get-GitHubMarkdown - Gets the rendered markdown for provided text' { { Get-GitHubMarkdown -Text 'Hello, World!' } | Should -Not -Throw } - It 'Can be called with Text parameter and GitHub Format Mardown' { + It 'Get-GitHubMarkdown - Gets the rendered markdown for provided text using GitHub Formated Markdown' { { Get-GitHubMarkdown -Text 'Hello, World!' -Mode gfm } | Should -Not -Throw } - It 'Raw - Can be called with Text parameter' { + It 'Get-GitHubMarkdownRaw - Gets the raw rendered markdown for provided text' { { Get-GitHubMarkdownRaw -Text 'Hello, World!' } | Should -Not -Throw } } Context 'User' { - It 'Can be called with Username parameter' { + It 'Get-GitHubUser - Gets the authenticated user' { + { Get-GitHubUser } | Should -Not -Throw + } + It 'Get-GitHubUser - Get the specified user' { { Get-GitHubUser -Username 'Octocat' } | Should -Not -Throw } + It 'Get-GitHubUser - Can set configuration on a user' { + $user = Get-GitHubUser + $params = @{ + Name = 'Octocat' + Email = 'psmodule@psmodule.io' + Blog = 'https://marius-storhaug.com' + TwitterUsername = 'MariusStorhaug123' + Company = 'PSModule' + Location = 'USA' + Hireable = $true + Bio = 'I love programming' + } + { Set-GitHubUser @params } | Should -Not -Throw + $tmpUser = Get-GitHubUser + $tmpUser.Name | Should -Be 'Octocat' + $tmpUser.Email | Should -Be 'psmodule@psmodule.io' + $tmpUser.Blog | Should -Be 'https://marius-storhaug.com' + $tmpUser.TwitterUsername | Should -Be 'MariusStorhaug123' + $tmpUser.Company | Should -Be 'PSModule' + $tmpUser.Location | Should -Be 'USA' + $tmpUser.Hireable | Should -Be $true + $tmpUser.Bio | Should -Be 'I love programming' + $user = @{ + Name = $user.Name + Email = $user.Email + Blog = $user.Blog + TwitterUsername = $user.TwitterUsername + Company = $user.Company + Location = $user.Location + Hireable = $user.Hireable + Bio = $user.Bio + } + Set-GitHubUser @user + } } } From 44950d0fa44ae3d463cf0f5c2baaf1b3dc941466 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Wed, 25 Dec 2024 09:55:26 +0100 Subject: [PATCH 06/16] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Move=20Get-GitH?= =?UTF-8?q?ubUserCard=20function=20to=20private=20scope=20and=20add=20deta?= =?UTF-8?q?iled=20documentation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/functions/{public => private}/Users/Get-GitHubUserCard.ps1 | 0 src/functions/public/Auth/Connect-GitHubApp.ps1 | 1 + 2 files changed, 1 insertion(+) rename src/functions/{public => private}/Users/Get-GitHubUserCard.ps1 (100%) diff --git a/src/functions/public/Users/Get-GitHubUserCard.ps1 b/src/functions/private/Users/Get-GitHubUserCard.ps1 similarity index 100% rename from src/functions/public/Users/Get-GitHubUserCard.ps1 rename to src/functions/private/Users/Get-GitHubUserCard.ps1 diff --git a/src/functions/public/Auth/Connect-GitHubApp.ps1 b/src/functions/public/Auth/Connect-GitHubApp.ps1 index d2ba3e23c..568d97521 100644 --- a/src/functions/public/Auth/Connect-GitHubApp.ps1 +++ b/src/functions/public/Auth/Connect-GitHubApp.ps1 @@ -34,6 +34,7 @@ .NOTES [Authenticating to the REST API](https://docs.github.com/rest/overview/other-authentication-methods#authenticating-for-saml-sso) #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([void])] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '', Justification = 'Is the CLI part of the module.')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '', From fccd1c3d357674493c5020c256042eed33f7e4df Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Wed, 25 Dec 2024 19:29:00 +0100 Subject: [PATCH 07/16] Refactor user retrieval functions for improved clarity and maintainability --- tests/GitHub.Tests.ps1 | 274 ++++++++++++++++++----------------------- 1 file changed, 119 insertions(+), 155 deletions(-) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index ffecc8831..e2a8921cb 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -50,6 +50,7 @@ Describe 'GitHub' { $context | Should -Not -BeNullOrEmpty } It 'Disconnect-GitHubAccount - Disconnects the context from the pipeline' { + $context = Get-GitHubContext { $context | Disconnect-GitHubAccount } | Should -Not -Throw } It 'Connect-GitHubAccount - Connects GitHub Actions even if called multiple times' { @@ -57,9 +58,9 @@ Describe 'GitHub' { { Connect-GitHubAccount } | Should -Not -Throw } It 'Connect-GitHubAccount - Connects multiple contexts, GitHub Actions and a user via classic PAT token' { - { Connect-GitHubAccount } | Should -Not -Throw { Connect-GitHubAccount -Token $env:TEST_USER_PAT } | Should -Not -Throw { Connect-GitHubAccount -Token $env:TEST_USER_PAT } | Should -Not -Throw + { Connect-GitHubAccount } | Should -Not -Throw (Get-GitHubContext -ListAvailable).Count | Should -Be 2 Get-GitHubConfig -Name 'DefaultContext' | Should -Be 'github.com/github-actions/Organization/PSModule' Write-Verbose (Get-GitHubContext | Out-String) -Verbose @@ -235,7 +236,7 @@ Describe 'GitHub' { } } -Describe 'As a user - Fine-grained PAT token - user account access' { +Describe 'As a user - Fine-grained PAT token - user account access (USER_FG_PAT)' { BeforeAll { Connect-GitHubAccount -Token $env:TEST_USER_USER_FG_PAT } @@ -243,12 +244,12 @@ Describe 'As a user - Fine-grained PAT token - user account access' { Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount } Context 'Auth' { - It 'Get-GitHubViewer - Gets the logged in context' { + It 'Get-GitHubViewer - Gets the logged in context (USER_FG_PAT)' { Get-GitHubViewer | Should -Not -BeNullOrEmpty } } Context 'API' { - It 'Invoke-GitHubAPI - Gets the rate limits directly' { + It 'Invoke-GitHubAPI - Gets the rate limits directly (USER_FG_PAT)' { { $rateLimit = Invoke-GitHubAPI -ApiEndpoint '/rate_limit' Write-Verbose ($rateLimit | Format-Table | Out-String) -Verbose @@ -256,7 +257,7 @@ Describe 'As a user - Fine-grained PAT token - user account access' { } } Context 'GraphQL' { - It 'Invoke-GitHubGraphQLQuery - Gets the viewer directly' { + It 'Invoke-GitHubGraphQLQuery - Gets the viewer directly (USER_FG_PAT)' { { $viewer = Invoke-GitHubGraphQLQuery -Query 'query { viewer { login } }' Write-Verbose ($viewer | Format-Table | Out-String) -Verbose @@ -264,103 +265,103 @@ Describe 'As a user - Fine-grained PAT token - user account access' { } } Context 'Meta' { - It 'Get-GitHubRoot - Gets the GitHub API Root' { + It 'Get-GitHubRoot - Gets the GitHub API Root (USER_FG_PAT)' { $root = Get-GitHubRoot Write-Verbose ($root | Format-Table | Out-String) -Verbose $root | Should -Not -BeNullOrEmpty } - It 'Get-GitHubApiVersion - Gets all API versions' { + It 'Get-GitHubApiVersion - Gets all API versions (USER_FG_PAT)' { $apiVersion = Get-GitHubApiVersion Write-Verbose ($apiVersion | Format-Table | Out-String) -Verbose $apiVersion | Should -Not -BeNullOrEmpty } - It 'Get-GitHubMeta - Gets GitHub meta information' { + It 'Get-GitHubMeta - Gets GitHub meta information (USER_FG_PAT)' { $meta = Get-GitHubMeta Write-Verbose ($meta | Format-Table | Out-String) -Verbose $meta | Should -Not -BeNullOrEmpty } - It 'Get-GitHubOctocat - Gets the Octocat' { + It 'Get-GitHubOctocat - Gets the Octocat (USER_FG_PAT)' { $octocat = Get-GitHubOctocat Write-Verbose ($octocat | Format-Table | Out-String) -Verbose $octocat | Should -Not -BeNullOrEmpty } - It 'Get-GitHubZen - Gets the Zen of GitHub' { + It 'Get-GitHubZen - Gets the Zen of GitHub (USER_FG_PAT)' { $zen = Get-GitHubZen Write-Verbose ($zen | Format-Table | Out-String) -Verbose $zen | Should -Not -BeNullOrEmpty } } Context 'Rate-Limit' { - It 'Get-GitHubRateLimit - Gets the rate limit status for the authenticated user' { + It 'Get-GitHubRateLimit - Gets the rate limit status for the authenticated user (USER_FG_PAT)' { { Get-GitHubRateLimit } | Should -Not -Throw } } Context 'License' { - It 'Get-GitHubLicense - Gets a list of all popular license templates' { + It 'Get-GitHubLicense - Gets a list of all popular license templates (USER_FG_PAT)' { { Get-GitHubLicense } | Should -Not -Throw } - It 'Get-GitHubLicense - Gets a spesific license' { + It 'Get-GitHubLicense - Gets a spesific license (USER_FG_PAT)' { { Get-GitHubLicense -Name 'mit' } | Should -Not -Throw } - It 'Get-GitHubLicense - Gets a license from a repository' { + It 'Get-GitHubLicense - Gets a license from a repository (USER_FG_PAT)' { { Get-GitHubLicense -Owner 'PSModule' -Repo 'GitHub' } | Should -Not -Throw } } Context 'Emoji' { - It 'Get-GitHubEmoji - Gets a list of all emojis' { + It 'Get-GitHubEmoji - Gets a list of all emojis (USER_FG_PAT)' { { Get-GitHubEmoji } | Should -Not -Throw } - It 'Get-GitHubEmoji - Downloads all emojis' { + It 'Get-GitHubEmoji - Downloads all emojis (USER_FG_PAT)' { { Get-GitHubEmoji -Destination $Home } | Should -Not -Throw } } Context 'Repository' { - It "Get-GitHubRepository - Gets the authenticated user's repositories" { + It "Get-GitHubRepository - Gets the authenticated user's repositories (USER_FG_PAT)" { { Get-GitHubRepository } | Should -Not -Throw } - It "Get-GitHubRepository - Gets the authenticated user's public repositories" { + It "Get-GitHubRepository - Gets the authenticated user's public repositories (USER_FG_PAT)" { { Get-GitHubRepository -Type 'public' } | Should -Not -Throw } - It 'Get-GitHubRepository - Gets the public repos where the authenticated user is owner' { + It 'Get-GitHubRepository - Gets the public repos where the authenticated user is owner (USER_FG_PAT)' { { Get-GitHubRepository -Visibility 'public' -Affiliation 'owner' } | Should -Not -Throw } - It 'Get-GitHubRepository - Gets a specific repository' { + It 'Get-GitHubRepository - Gets a specific repository (USER_FG_PAT)' { { Get-GitHubRepository -Owner 'PSModule' -Repo 'GitHub' } | Should -Not -Throw } - It 'Get-GitHubRepository - Gets all repositories from a organization' { + It 'Get-GitHubRepository - Gets all repositories from a organization (USER_FG_PAT)' { { Get-GitHubRepository -Owner 'PSModule' } | Should -Not -Throw } - It 'Get-GitHubRepository - Gets all repositories from a user' { + It 'Get-GitHubRepository - Gets all repositories from a user (USER_FG_PAT)' { { Get-GitHubRepository -Username 'MariusStorhaug' } | Should -Not -Throw } } Context 'GitIgnore' { - It 'Get-GitHubGitignore - Gets a list of all gitignore templates names' { + It 'Get-GitHubGitignore - Gets a list of all gitignore templates names (USER_FG_PAT)' { { Get-GitHubGitignore } | Should -Not -Throw } - It 'Get-GitHubGitignore - Gets a gitignore template' { + It 'Get-GitHubGitignore - Gets a gitignore template (USER_FG_PAT)' { { Get-GitHubGitignore -Name 'VisualStudio' } | Should -Not -Throw } } Context 'Markdown' { - It 'Get-GitHubMarkdown - Gets the rendered markdown for provided text' { + It 'Get-GitHubMarkdown - Gets the rendered markdown for provided text (USER_FG_PAT)' { { Get-GitHubMarkdown -Text 'Hello, World!' } | Should -Not -Throw } - It 'Get-GitHubMarkdown - Gets the rendered markdown for provided text using GitHub Formated Markdown' { + It 'Get-GitHubMarkdown - Gets the rendered markdown for provided text using GitHub Formated Markdown (USER_FG_PAT)' { { Get-GitHubMarkdown -Text 'Hello, World!' -Mode gfm } | Should -Not -Throw } - It 'Get-GitHubMarkdownRaw - Gets the raw rendered markdown for provided text' { + It 'Get-GitHubMarkdownRaw - Gets the raw rendered markdown for provided text (USER_FG_PAT)' { { Get-GitHubMarkdownRaw -Text 'Hello, World!' } | Should -Not -Throw } } Context 'User' { - It 'Get-GitHubUser - Gets the authenticated user' { + It 'Get-GitHubUser - Gets the authenticated user (USER_FG_PAT)' { { Get-GitHubUser } | Should -Not -Throw } - It 'Get-GitHubUser - Get the specified user' { + It 'Get-GitHubUser - Get the specified user (USER_FG_PAT)' { { Get-GitHubUser -Username 'Octocat' } | Should -Not -Throw } - It 'Get-GitHubUser - Can set configuration on a user' { + It 'Get-GitHubUser - Can set configuration on a user (USER_FG_PAT)' { $user = Get-GitHubUser $params = @{ Name = 'Octocat' @@ -397,7 +398,7 @@ Describe 'As a user - Fine-grained PAT token - user account access' { } } -Describe 'As a user - Fine-grained PAT token - organization account access' { +Describe 'As a user - Fine-grained PAT token - organization account access (ORG_FG_PAT)' { BeforeAll { Connect-GitHubAccount -Token $env:TEST_USER_ORG_FG_PAT } @@ -405,12 +406,12 @@ Describe 'As a user - Fine-grained PAT token - organization account access' { Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount } Context 'Auth' { - It 'Get-GitHubViewer - Gets the logged in context' { + It 'Get-GitHubViewer - Gets the logged in context (ORG_FG_PAT)' { Get-GitHubViewer | Should -Not -BeNullOrEmpty } } Context 'API' { - It 'Invoke-GitHubAPI - Gets the rate limits directly' { + It 'Invoke-GitHubAPI - Gets the rate limits directly (ORG_FG_PAT)' { { $rateLimit = Invoke-GitHubAPI -ApiEndpoint '/rate_limit' Write-Verbose ($rateLimit | Format-Table | Out-String) -Verbose @@ -418,7 +419,7 @@ Describe 'As a user - Fine-grained PAT token - organization account access' { } } Context 'GraphQL' { - It 'Invoke-GitHubGraphQLQuery - Gets the viewer directly' { + It 'Invoke-GitHubGraphQLQuery - Gets the viewer directly (ORG_FG_PAT)' { { $viewer = Invoke-GitHubGraphQLQuery -Query 'query { viewer { login } }' Write-Verbose ($viewer | Format-Table | Out-String) -Verbose @@ -426,103 +427,103 @@ Describe 'As a user - Fine-grained PAT token - organization account access' { } } Context 'Meta' { - It 'Get-GitHubRoot - Gets the GitHub API Root' { + It 'Get-GitHubRoot - Gets the GitHub API Root (ORG_FG_PAT)' { $root = Get-GitHubRoot Write-Verbose ($root | Format-Table | Out-String) -Verbose $root | Should -Not -BeNullOrEmpty } - It 'Get-GitHubApiVersion - Gets all API versions' { + It 'Get-GitHubApiVersion - Gets all API versions (ORG_FG_PAT)' { $apiVersion = Get-GitHubApiVersion Write-Verbose ($apiVersion | Format-Table | Out-String) -Verbose $apiVersion | Should -Not -BeNullOrEmpty } - It 'Get-GitHubMeta - Gets GitHub meta information' { + It 'Get-GitHubMeta - Gets GitHub meta information (ORG_FG_PAT)' { $meta = Get-GitHubMeta Write-Verbose ($meta | Format-Table | Out-String) -Verbose $meta | Should -Not -BeNullOrEmpty } - It 'Get-GitHubOctocat - Gets the Octocat' { + It 'Get-GitHubOctocat - Gets the Octocat (ORG_FG_PAT)' { $octocat = Get-GitHubOctocat Write-Verbose ($octocat | Format-Table | Out-String) -Verbose $octocat | Should -Not -BeNullOrEmpty } - It 'Get-GitHubZen - Gets the Zen of GitHub' { + It 'Get-GitHubZen - Gets the Zen of GitHub (ORG_FG_PAT)' { $zen = Get-GitHubZen Write-Verbose ($zen | Format-Table | Out-String) -Verbose $zen | Should -Not -BeNullOrEmpty } } Context 'Rate-Limit' { - It 'Get-GitHubRateLimit - Gets the rate limit status for the authenticated user' { + It 'Get-GitHubRateLimit - Gets the rate limit status for the authenticated user (ORG_FG_PAT)' { { Get-GitHubRateLimit } | Should -Not -Throw } } Context 'License' { - It 'Get-GitHubLicense - Gets a list of all popular license templates' { + It 'Get-GitHubLicense - Gets a list of all popular license templates (ORG_FG_PAT)' { { Get-GitHubLicense } | Should -Not -Throw } - It 'Get-GitHubLicense - Gets a spesific license' { + It 'Get-GitHubLicense - Gets a spesific license (ORG_FG_PAT)' { { Get-GitHubLicense -Name 'mit' } | Should -Not -Throw } - It 'Get-GitHubLicense - Gets a license from a repository' { + It 'Get-GitHubLicense - Gets a license from a repository (ORG_FG_PAT)' { { Get-GitHubLicense -Owner 'PSModule' -Repo 'GitHub' } | Should -Not -Throw } } Context 'Emoji' { - It 'Get-GitHubEmoji - Gets a list of all emojis' { + It 'Get-GitHubEmoji - Gets a list of all emojis (ORG_FG_PAT)' { { Get-GitHubEmoji } | Should -Not -Throw } - It 'Get-GitHubEmoji - Downloads all emojis' { + It 'Get-GitHubEmoji - Downloads all emojis (ORG_FG_PAT)' { { Get-GitHubEmoji -Destination $Home } | Should -Not -Throw } } Context 'Repository' { - It "Get-GitHubRepository - Gets the authenticated user's repositories" { + It "Get-GitHubRepository - Gets the authenticated user's repositories (ORG_FG_PAT)" { { Get-GitHubRepository } | Should -Not -Throw } - It "Get-GitHubRepository - Gets the authenticated user's public repositories" { + It "Get-GitHubRepository - Gets the authenticated user's public repositories (ORG_FG_PAT)" { { Get-GitHubRepository -Type 'public' } | Should -Not -Throw } - It 'Get-GitHubRepository - Gets the public repos where the authenticated user is owner' { + It 'Get-GitHubRepository - Gets the public repos where the authenticated user is owner (ORG_FG_PAT)' { { Get-GitHubRepository -Visibility 'public' -Affiliation 'owner' } | Should -Not -Throw } - It 'Get-GitHubRepository - Gets a specific repository' { + It 'Get-GitHubRepository - Gets a specific repository (ORG_FG_PAT)' { { Get-GitHubRepository -Owner 'PSModule' -Repo 'GitHub' } | Should -Not -Throw } - It 'Get-GitHubRepository - Gets all repositories from a organization' { + It 'Get-GitHubRepository - Gets all repositories from a organization (ORG_FG_PAT)' { { Get-GitHubRepository -Owner 'PSModule' } | Should -Not -Throw } - It 'Get-GitHubRepository - Gets all repositories from a user' { + It 'Get-GitHubRepository - Gets all repositories from a user (ORG_FG_PAT)' { { Get-GitHubRepository -Username 'MariusStorhaug' } | Should -Not -Throw } } Context 'GitIgnore' { - It 'Get-GitHubGitignore - Gets a list of all gitignore templates names' { + It 'Get-GitHubGitignore - Gets a list of all gitignore templates names (ORG_FG_PAT)' { { Get-GitHubGitignore } | Should -Not -Throw } - It 'Get-GitHubGitignore - Gets a gitignore template' { + It 'Get-GitHubGitignore - Gets a gitignore template (ORG_FG_PAT)' { { Get-GitHubGitignore -Name 'VisualStudio' } | Should -Not -Throw } } Context 'Markdown' { - It 'Get-GitHubMarkdown - Gets the rendered markdown for provided text' { + It 'Get-GitHubMarkdown - Gets the rendered markdown for provided text (ORG_FG_PAT)' { { Get-GitHubMarkdown -Text 'Hello, World!' } | Should -Not -Throw } - It 'Get-GitHubMarkdown - Gets the rendered markdown for provided text using GitHub Formated Markdown' { + It 'Get-GitHubMarkdown - Gets the rendered markdown for provided text using GitHub Formated Markdown (ORG_FG_PAT)' { { Get-GitHubMarkdown -Text 'Hello, World!' -Mode gfm } | Should -Not -Throw } - It 'Get-GitHubMarkdownRaw - Gets the raw rendered markdown for provided text' { + It 'Get-GitHubMarkdownRaw - Gets the raw rendered markdown for provided text (ORG_FG_PAT)' { { Get-GitHubMarkdownRaw -Text 'Hello, World!' } | Should -Not -Throw } } Context 'User' { - It 'Get-GitHubUser - Gets the authenticated user' { + It 'Get-GitHubUser - Gets the authenticated user (ORG_FG_PAT)' { { Get-GitHubUser } | Should -Not -Throw } - It 'Get-GitHubUser - Get the specified user' { + It 'Get-GitHubUser - Get the specified user (ORG_FG_PAT)' { { Get-GitHubUser -Username 'Octocat' } | Should -Not -Throw } - It 'Get-GitHubUser - Can set configuration on a user' { + It 'Get-GitHubUser - Can set configuration on a user (ORG_FG_PAT)' { $user = Get-GitHubUser $params = @{ Name = 'Octocat' @@ -559,7 +560,7 @@ Describe 'As a user - Fine-grained PAT token - organization account access' { } } -Describe 'As a user - Classic PAT token' { +Describe 'As a user - Classic PAT token (PAT)' { BeforeAll { Connect-GitHubAccount -Token $env:TEST_USER_PAT } @@ -567,12 +568,12 @@ Describe 'As a user - Classic PAT token' { Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount } Context 'Auth' { - It 'Get-GitHubViewer - Gets the logged in context' { + It 'Get-GitHubViewer - Gets the logged in context (PAT)' { Get-GitHubViewer | Should -Not -BeNullOrEmpty } } Context 'API' { - It 'Invoke-GitHubAPI - Gets the rate limits directly' { + It 'Invoke-GitHubAPI - Gets the rate limits directly (PAT)' { { $rateLimit = Invoke-GitHubAPI -ApiEndpoint '/rate_limit' Write-Verbose ($rateLimit | Format-Table | Out-String) -Verbose @@ -580,7 +581,7 @@ Describe 'As a user - Classic PAT token' { } } Context 'GraphQL' { - It 'Invoke-GitHubGraphQLQuery - Gets the viewer directly' { + It 'Invoke-GitHubGraphQLQuery - Gets the viewer directly (PAT)' { { $viewer = Invoke-GitHubGraphQLQuery -Query 'query { viewer { login } }' Write-Verbose ($viewer | Format-Table | Out-String) -Verbose @@ -588,83 +589,83 @@ Describe 'As a user - Classic PAT token' { } } Context 'Meta' { - It 'Get-GitHubRoot - Gets the GitHub API Root' { + It 'Get-GitHubRoot - Gets the GitHub API Root (PAT)' { $root = Get-GitHubRoot Write-Verbose ($root | Format-Table | Out-String) -Verbose $root | Should -Not -BeNullOrEmpty } - It 'Get-GitHubApiVersion - Gets all API versions' { + It 'Get-GitHubApiVersion - Gets all API versions (PAT)' { $apiVersion = Get-GitHubApiVersion Write-Verbose ($apiVersion | Format-Table | Out-String) -Verbose $apiVersion | Should -Not -BeNullOrEmpty } - It 'Get-GitHubMeta - Gets GitHub meta information' { + It 'Get-GitHubMeta - Gets GitHub meta information (PAT)' { $meta = Get-GitHubMeta Write-Verbose ($meta | Format-Table | Out-String) -Verbose $meta | Should -Not -BeNullOrEmpty } - It 'Get-GitHubOctocat - Gets the Octocat' { + It 'Get-GitHubOctocat - Gets the Octocat (PAT)' { $octocat = Get-GitHubOctocat Write-Verbose ($octocat | Format-Table | Out-String) -Verbose $octocat | Should -Not -BeNullOrEmpty } - It 'Get-GitHubZen - Gets the Zen of GitHub' { + It 'Get-GitHubZen - Gets the Zen of GitHub (PAT)' { $zen = Get-GitHubZen Write-Verbose ($zen | Format-Table | Out-String) -Verbose $zen | Should -Not -BeNullOrEmpty } } Context 'Rate-Limit' { - It 'Get-GitHubRateLimit - Gets the rate limit status for the authenticated user' { + It 'Get-GitHubRateLimit - Gets the rate limit status for the authenticated user (PAT)' { { Get-GitHubRateLimit } | Should -Not -Throw } } Context 'License' { - It 'Get-GitHubLicense - Gets a list of all popular license templates' { + It 'Get-GitHubLicense - Gets a list of all popular license templates (PAT)' { { Get-GitHubLicense } | Should -Not -Throw } - It 'Get-GitHubLicense - Gets a spesific license' { + It 'Get-GitHubLicense - Gets a spesific license (PAT)' { { Get-GitHubLicense -Name 'mit' } | Should -Not -Throw } - It 'Get-GitHubLicense - Gets a license from a repository' { + It 'Get-GitHubLicense - Gets a license from a repository (PAT)' { { Get-GitHubLicense -Owner 'PSModule' -Repo 'GitHub' } | Should -Not -Throw } } Context 'Emoji' { - It 'Get-GitHubEmoji - Gets a list of all emojis' { + It 'Get-GitHubEmoji - Gets a list of all emojis (PAT)' { { Get-GitHubEmoji } | Should -Not -Throw } - It 'Get-GitHubEmoji - Downloads all emojis' { + It 'Get-GitHubEmoji - Downloads all emojis (PAT)' { { Get-GitHubEmoji -Destination $Home } | Should -Not -Throw } } Context 'GitIgnore' { - It 'Get-GitHubGitignore - Gets a list of all gitignore templates names' { + It 'Get-GitHubGitignore - Gets a list of all gitignore templates names (PAT)' { { Get-GitHubGitignore } | Should -Not -Throw } - It 'Get-GitHubGitignore - Gets a gitignore template' { + It 'Get-GitHubGitignore - Gets a gitignore template (PAT)' { { Get-GitHubGitignore -Name 'VisualStudio' } | Should -Not -Throw } } Context 'Markdown' { - It 'Get-GitHubMarkdown - Gets the rendered markdown for provided text' { + It 'Get-GitHubMarkdown - Gets the rendered markdown for provided text (PAT)' { { Get-GitHubMarkdown -Text 'Hello, World!' } | Should -Not -Throw } - It 'Get-GitHubMarkdown - Gets the rendered markdown for provided text using GitHub Formated Markdown' { + It 'Get-GitHubMarkdown - Gets the rendered markdown for provided text using GitHub Formated Markdown (PAT)' { { Get-GitHubMarkdown -Text 'Hello, World!' -Mode gfm } | Should -Not -Throw } - It 'Get-GitHubMarkdownRaw - Gets the raw rendered markdown for provided text' { + It 'Get-GitHubMarkdownRaw - Gets the raw rendered markdown for provided text (PAT)' { { Get-GitHubMarkdownRaw -Text 'Hello, World!' } | Should -Not -Throw } } Context 'User' { - It 'Get-GitHubUser - Gets the authenticated user' { + It 'Get-GitHubUser - Gets the authenticated user (PAT)' { { Get-GitHubUser } | Should -Not -Throw } - It 'Get-GitHubUser - Get the specified user' { + It 'Get-GitHubUser - Get the specified user (PAT)' { { Get-GitHubUser -Username 'Octocat' } | Should -Not -Throw } - It 'Get-GitHubUser - Can set configuration on a user' { + It 'Get-GitHubUser - Can set configuration on a user (PAT)' { $user = Get-GitHubUser $params = @{ Name = 'Octocat' @@ -701,7 +702,7 @@ Describe 'As a user - Classic PAT token' { } } -Describe 'As GitHub Actions' { +Describe 'As GitHub Actions (GHA)' { BeforeAll { Connect-GitHubAccount } @@ -709,12 +710,12 @@ Describe 'As GitHub Actions' { Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount } Context 'Auth' { - It 'Get-GitHubViewer - Gets the logged in context' { + It 'Get-GitHubViewer - Gets the logged in context (GHA)' { Get-GitHubViewer | Should -Not -BeNullOrEmpty } } Context 'API' { - It 'Invoke-GitHubAPI - Gets the rate limits directly' { + It 'Invoke-GitHubAPI - Gets the rate limits directly (GHA)' { { $rateLimit = Invoke-GitHubAPI -ApiEndpoint '/rate_limit' Write-Verbose ($rateLimit | Format-Table | Out-String) -Verbose @@ -722,7 +723,7 @@ Describe 'As GitHub Actions' { } } Context 'GraphQL' { - It 'Invoke-GitHubGraphQLQuery - Gets the viewer directly' { + It 'Invoke-GitHubGraphQLQuery - Gets the viewer directly (GHA)' { { $viewer = Invoke-GitHubGraphQLQuery -Query 'query { viewer { login } }' Write-Verbose ($viewer | Format-Table | Out-String) -Verbose @@ -730,7 +731,7 @@ Describe 'As GitHub Actions' { } } Context 'Git' { - It 'Set-GitHubGitConfig sets the Git configuration' { + It 'Set-GitHubGitConfig sets the Git configuration (GHA)' { { Set-GitHubGitConfig } | Should -Not -Throw $gitConfig = Get-GitHubGitConfig Write-Verbose ($gitConfig | Format-Table | Out-String) -Verbose @@ -741,120 +742,83 @@ Describe 'As GitHub Actions' { } } Context 'Meta' { - It 'Get-GitHubRoot - Gets the GitHub API Root' { + It 'Get-GitHubRoot - Gets the GitHub API Root (GHA)' { $root = Get-GitHubRoot Write-Verbose ($root | Format-Table | Out-String) -Verbose $root | Should -Not -BeNullOrEmpty } - It 'Get-GitHubApiVersion - Gets all API versions' { + It 'Get-GitHubApiVersion - Gets all API versions (GHA)' { $apiVersion = Get-GitHubApiVersion Write-Verbose ($apiVersion | Format-Table | Out-String) -Verbose $apiVersion | Should -Not -BeNullOrEmpty } - It 'Get-GitHubMeta - Gets GitHub meta information' { + It 'Get-GitHubMeta - Gets GitHub meta information (GHA)' { $meta = Get-GitHubMeta Write-Verbose ($meta | Format-Table | Out-String) -Verbose $meta | Should -Not -BeNullOrEmpty } - It 'Get-GitHubOctocat - Gets the Octocat' { + It 'Get-GitHubOctocat - Gets the Octocat (GHA)' { $octocat = Get-GitHubOctocat Write-Verbose ($octocat | Format-Table | Out-String) -Verbose $octocat | Should -Not -BeNullOrEmpty } - It 'Get-GitHubZen - Gets the Zen of GitHub' { + It 'Get-GitHubZen - Gets the Zen of GitHub (GHA)' { $zen = Get-GitHubZen Write-Verbose ($zen | Format-Table | Out-String) -Verbose $zen | Should -Not -BeNullOrEmpty } } Context 'Rate-Limit' { - It 'Get-GitHubRateLimit - Gets the rate limit status for the authenticated user' { + It 'Get-GitHubRateLimit - Gets the rate limit status for the authenticated user (GHA)' { { Get-GitHubRateLimit } | Should -Not -Throw } } Context 'License' { - It 'Get-GitHubLicense - Gets a list of all popular license templates' { + It 'Get-GitHubLicense - Gets a list of all popular license templates (GHA)' { { Get-GitHubLicense } | Should -Not -Throw } - It 'Get-GitHubLicense - Gets a spesific license' { + It 'Get-GitHubLicense - Gets a spesific license (GHA)' { { Get-GitHubLicense -Name 'mit' } | Should -Not -Throw } - It 'Get-GitHubLicense - Gets a license from a repository' { + It 'Get-GitHubLicense - Gets a license from a repository (GHA)' { { Get-GitHubLicense -Owner 'PSModule' -Repo 'GitHub' } | Should -Not -Throw } } Context 'Emoji' { - It 'Get-GitHubEmoji - Gets a list of all emojis' { + It 'Get-GitHubEmoji - Gets a list of all emojis (GHA)' { { Get-GitHubEmoji } | Should -Not -Throw } - It 'Get-GitHubEmoji - Downloads all emojis' { + It 'Get-GitHubEmoji - Downloads all emojis (GHA)' { { Get-GitHubEmoji -Destination $Home } | Should -Not -Throw } } Context 'GitIgnore' { - It 'Get-GitHubGitignore - Gets a list of all gitignore templates names' { + It 'Get-GitHubGitignore - Gets a list of all gitignore templates names (GHA)' { { Get-GitHubGitignore } | Should -Not -Throw } - It 'Get-GitHubGitignore - Gets a gitignore template' { + It 'Get-GitHubGitignore - Gets a gitignore template (GHA)' { { Get-GitHubGitignore -Name 'VisualStudio' } | Should -Not -Throw } } Context 'Markdown' { - It 'Get-GitHubMarkdown - Gets the rendered markdown for provided text' { + It 'Get-GitHubMarkdown - Gets the rendered markdown for provided text (GHA)' { { Get-GitHubMarkdown -Text 'Hello, World!' } | Should -Not -Throw } - It 'Get-GitHubMarkdown - Gets the rendered markdown for provided text using GitHub Formated Markdown' { + It 'Get-GitHubMarkdown - Gets the rendered markdown for provided text using GitHub Formated Markdown (GHA)' { { Get-GitHubMarkdown -Text 'Hello, World!' -Mode gfm } | Should -Not -Throw } - It 'Get-GitHubMarkdownRaw - Gets the raw rendered markdown for provided text' { + It 'Get-GitHubMarkdownRaw - Gets the raw rendered markdown for provided text (GHA)' { { Get-GitHubMarkdownRaw -Text 'Hello, World!' } | Should -Not -Throw } } Context 'User' { - It 'Get-GitHubUser - Gets the authenticated user' { - { Get-GitHubUser } | Should -Not -Throw - } - It 'Get-GitHubUser - Get the specified user' { + It 'Get-GitHubUser - Get the specified user (GHA)' { { Get-GitHubUser -Username 'Octocat' } | Should -Not -Throw } - It 'Get-GitHubUser - Can set configuration on a user' { - $user = Get-GitHubUser - $params = @{ - Name = 'Octocat' - Email = 'psmodule@psmodule.io' - Blog = 'https://marius-storhaug.com' - TwitterUsername = 'MariusStorhaug123' - Company = 'PSModule' - Location = 'USA' - Hireable = $true - Bio = 'I love programming' - } - { Set-GitHubUser @params } | Should -Not -Throw - $tmpUser = Get-GitHubUser - $tmpUser.Name | Should -Be 'Octocat' - $tmpUser.Email | Should -Be 'psmodule@psmodule.io' - $tmpUser.Blog | Should -Be 'https://marius-storhaug.com' - $tmpUser.TwitterUsername | Should -Be 'MariusStorhaug123' - $tmpUser.Company | Should -Be 'PSModule' - $tmpUser.Location | Should -Be 'USA' - $tmpUser.Hireable | Should -Be $true - $tmpUser.Bio | Should -Be 'I love programming' - $user = @{ - Name = $user.Name - Email = $user.Email - Blog = $user.Blog - TwitterUsername = $user.TwitterUsername - Company = $user.Company - Location = $user.Location - Hireable = $user.Hireable - Bio = $user.Bio - } - Set-GitHubUser @user - } } } -Describe 'As a GitHub App - Enterprise' { +Describe 'As a GitHub App - Enterprise (APP_ENT)' { BeforeAll { Connect-GitHubAccount -ClientID $env:TEST_APP_ENT_CLIENT_ID -PrivateKey $env:TEST_APP_ENT_PRIVATE_KEY } @@ -862,12 +826,12 @@ Describe 'As a GitHub App - Enterprise' { Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount } Context 'User' { - It 'Can be called with Username parameter' { + It 'Can be called with Username parameter (APP_ENT)' { { Get-GitHubUser -Username 'Octocat' } | Should -Not -Throw } } Context 'App' { - It 'Can get the authenticated GitHubApp' { + It 'Can get the authenticated GitHubApp (APP_ENT)' { $app = Get-GitHubApp Write-Verbose ($app | Format-Table | Out-String) -Verbose $app | Should -Not -BeNullOrEmpty @@ -875,7 +839,7 @@ Describe 'As a GitHub App - Enterprise' { } } -Describe 'As a GitHub App - Organization' { +Describe 'As a GitHub App - Organization (APP_ORG)' { BeforeAll { Connect-GitHubAccount -ClientID $env:TEST_APP_ORG_CLIENT_ID -PrivateKey $env:TEST_APP_ORG_PRIVATE_KEY } @@ -884,22 +848,22 @@ Describe 'As a GitHub App - Organization' { } Context 'Apps' { Context 'GitHub Apps' { - It 'Can get a JWT for the app' { + It 'Can get a JWT for the app (APP_ENT)' { $jwt = Get-GitHubAppJSONWebToken -ClientId $env:TEST_APP_ORG_CLIENT_ID -PrivateKey $env:TEST_APP_ORG_PRIVATE_KEY Write-Verbose ($jwt | Format-Table | Out-String) -Verbose $jwt | Should -Not -BeNullOrEmpty } - It 'Can get app details' { + It 'Can get app details (APP_ENT)' { $app = Get-GitHubApp Write-Verbose ($app | Format-Table | Out-String) -Verbose $app | Should -Not -BeNullOrEmpty } - It 'Can get app installations' { + It 'Can get app installations (APP_ENT)' { $installations = Get-GitHubAppInstallation Write-Verbose ($installations | Format-Table | Out-String) -Verbose $installations | Should -Not -BeNullOrEmpty } - It 'Can get app installation access tokens' { + It 'Can get app installation access tokens (APP_ENT)' { $installations = Get-GitHubAppInstallation $installations | ForEach-Object { $token = New-GitHubAppInstallationAccessToken -InstallationID $_.id @@ -909,28 +873,28 @@ Describe 'As a GitHub App - Organization' { } } Context 'Webhooks' { - It 'Can get the webhook configuration' { + It 'Can get the webhook configuration (APP_ENT)' { $webhooks = Get-GitHubAppWebhookConfiguration Write-Verbose ($webhooks | Format-Table | Out-String) -Verbose $webhooks | Should -Not -BeNullOrEmpty } - It 'Can update the webhook configuration' { + It 'Can update the webhook configuration (APP_ENT)' { { Update-GitHubAppWebhookConfiguration -ContentType 'form' } | Should -Not -Throw { Update-GitHubAppWebhookConfiguration -ContentType 'json' } | Should -Not -Throw } - It 'Can get webhook deliveries' { + It 'Can get webhook deliveries (APP_ENT)' { $deliveries = Get-GitHubAppWebhookDelivery Write-Verbose ($deliveries | Format-Table | Out-String) -Verbose $deliveries | Should -Not -BeNullOrEmpty } - It 'Can redeliver a webhook delivery' { + It 'Can redeliver a webhook delivery (APP_ENT)' { $deliveries = Get-GitHubAppWebhookDelivery | Select-Object -First 1 { Invoke-GitHubAppWebhookReDelivery -ID $deliveries.id } | Should -Not -Throw } } } Context 'API' { - It 'Can be called directly to get ratelimits' { + It 'Can be called directly to get ratelimits (APP_ENT)' { { $app = Invoke-GitHubAPI -ApiEndpoint '/app' Write-Verbose ($app | Format-Table | Out-String) -Verbose @@ -938,7 +902,7 @@ Describe 'As a GitHub App - Organization' { } } Context 'User' { - It 'Can be called with Username parameter' { + It 'Can be called with Username parameter (APP_ENT)' { { Get-GitHubUser -Username 'Octocat' } | Should -Not -Throw } } From 99a0f4b41541461436b9b2b7ef2552adac0a604b Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Wed, 25 Dec 2024 20:30:48 +0100 Subject: [PATCH 08/16] Refactor user configuration tests for improved readability and maintainability --- tests/GitHub.Tests.ps1 | 180 ++++++++++++++++++++++++++--------------- 1 file changed, 114 insertions(+), 66 deletions(-) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index e2a8921cb..43d59e5ca 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -362,18 +362,26 @@ Describe 'As a user - Fine-grained PAT token - user account access (USER_FG_PAT) { Get-GitHubUser -Username 'Octocat' } | Should -Not -Throw } It 'Get-GitHubUser - Can set configuration on a user (USER_FG_PAT)' { + # $params = @{ + # Name = 'Octocat' + # Email = 'psmodule@psmodule.io' + # Blog = 'https://marius-storhaug.com' + # TwitterUsername = 'MariusStorhaug123' + # Company = 'PSModule' + # Location = 'USA' + # Hireable = $true + # Bio = 'I love programming' + # } + # { Set-GitHubUser @params } | Should -Not -Throw $user = Get-GitHubUser - $params = @{ - Name = 'Octocat' - Email = 'psmodule@psmodule.io' - Blog = 'https://marius-storhaug.com' - TwitterUsername = 'MariusStorhaug123' - Company = 'PSModule' - Location = 'USA' - Hireable = $true - Bio = 'I love programming' - } - { Set-GitHubUser @params } | Should -Not -Throw + { Set-GitHubUser -Name 'Octocat' } | Should -Not -Throw + { Set-GitHubUser -Email 'psmodule@psmodule.io' } | Should -Not -Throw + { Set-GitHubUser -Blog 'https://marius-storhaug.com' } | Should -Not -Throw + { Set-GitHubUser -TwitterUsername 'MariusStorhaug123' } | Should -Not -Throw + { Set-GitHubUser -Company 'PSModule' } | Should -Not -Throw + { Set-GitHubUser -Location 'USA' } | Should -Not -Throw + { Set-GitHubUser -Hireable $true } | Should -Not -Throw + { Set-GitHubUser -Bio 'I love programming' } | Should -Not -Throw $tmpUser = Get-GitHubUser $tmpUser.Name | Should -Be 'Octocat' $tmpUser.Email | Should -Be 'psmodule@psmodule.io' @@ -383,17 +391,25 @@ Describe 'As a user - Fine-grained PAT token - user account access (USER_FG_PAT) $tmpUser.Location | Should -Be 'USA' $tmpUser.Hireable | Should -Be $true $tmpUser.Bio | Should -Be 'I love programming' - $user = @{ - Name = $user.Name - Email = $user.Email - Blog = $user.Blog - TwitterUsername = $user.TwitterUsername - Company = $user.Company - Location = $user.Location - Hireable = $user.Hireable - Bio = $user.Bio - } - Set-GitHubUser @user + { Set-GitHubUser -Name $user.Name } | Should -Not -Throw + { Set-GitHubUser -Email $user.Email } | Should -Not -Throw + { Set-GitHubUser -Blog $user.Blog } | Should -Not -Throw + { Set-GitHubUser -TwitterUsername $user.TwitterUsername } | Should -Not -Throw + { Set-GitHubUser -Company $user.Company } | Should -Not -Throw + { Set-GitHubUser -Location $user.Location } | Should -Not -Throw + { Set-GitHubUser -Hireable $user.Hireable } | Should -Not -Throw + { Set-GitHubUser -Bio $user.Bio } | Should -Not -Throw + # $user = @{ + # Name = $user.Name + # Email = $user.Email + # Blog = $user.Blog + # TwitterUsername = $user.TwitterUsername + # Company = $user.Company + # Location = $user.Location + # Hireable = $user.Hireable + # Bio = $user.Bio + # } + # Set-GitHubUser @user } } } @@ -524,18 +540,26 @@ Describe 'As a user - Fine-grained PAT token - organization account access (ORG_ { Get-GitHubUser -Username 'Octocat' } | Should -Not -Throw } It 'Get-GitHubUser - Can set configuration on a user (ORG_FG_PAT)' { + # $params = @{ + # Name = 'Octocat' + # Email = 'psmodule@psmodule.io' + # Blog = 'https://marius-storhaug.com' + # TwitterUsername = 'MariusStorhaug123' + # Company = 'PSModule' + # Location = 'USA' + # Hireable = $true + # Bio = 'I love programming' + # } + # { Set-GitHubUser @params } | Should -Not -Throw $user = Get-GitHubUser - $params = @{ - Name = 'Octocat' - Email = 'psmodule@psmodule.io' - Blog = 'https://marius-storhaug.com' - TwitterUsername = 'MariusStorhaug123' - Company = 'PSModule' - Location = 'USA' - Hireable = $true - Bio = 'I love programming' - } - { Set-GitHubUser @params } | Should -Not -Throw + { Set-GitHubUser -Name 'Octocat' } | Should -Not -Throw + { Set-GitHubUser -Email 'psmodule@psmodule.io' } | Should -Not -Throw + { Set-GitHubUser -Blog 'https://marius-storhaug.com' } | Should -Not -Throw + { Set-GitHubUser -TwitterUsername 'MariusStorhaug123' } | Should -Not -Throw + { Set-GitHubUser -Company 'PSModule' } | Should -Not -Throw + { Set-GitHubUser -Location 'USA' } | Should -Not -Throw + { Set-GitHubUser -Hireable $true } | Should -Not -Throw + { Set-GitHubUser -Bio 'I love programming' } | Should -Not -Throw $tmpUser = Get-GitHubUser $tmpUser.Name | Should -Be 'Octocat' $tmpUser.Email | Should -Be 'psmodule@psmodule.io' @@ -545,17 +569,25 @@ Describe 'As a user - Fine-grained PAT token - organization account access (ORG_ $tmpUser.Location | Should -Be 'USA' $tmpUser.Hireable | Should -Be $true $tmpUser.Bio | Should -Be 'I love programming' - $user = @{ - Name = $user.Name - Email = $user.Email - Blog = $user.Blog - TwitterUsername = $user.TwitterUsername - Company = $user.Company - Location = $user.Location - Hireable = $user.Hireable - Bio = $user.Bio - } - Set-GitHubUser @user + { Set-GitHubUser -Name $user.Name } | Should -Not -Throw + { Set-GitHubUser -Email $user.Email } | Should -Not -Throw + { Set-GitHubUser -Blog $user.Blog } | Should -Not -Throw + { Set-GitHubUser -TwitterUsername $user.TwitterUsername } | Should -Not -Throw + { Set-GitHubUser -Company $user.Company } | Should -Not -Throw + { Set-GitHubUser -Location $user.Location } | Should -Not -Throw + { Set-GitHubUser -Hireable $user.Hireable } | Should -Not -Throw + { Set-GitHubUser -Bio $user.Bio } | Should -Not -Throw + # $user = @{ + # Name = $user.Name + # Email = $user.Email + # Blog = $user.Blog + # TwitterUsername = $user.TwitterUsername + # Company = $user.Company + # Location = $user.Location + # Hireable = $user.Hireable + # Bio = $user.Bio + # } + # Set-GitHubUser @user } } } @@ -666,18 +698,26 @@ Describe 'As a user - Classic PAT token (PAT)' { { Get-GitHubUser -Username 'Octocat' } | Should -Not -Throw } It 'Get-GitHubUser - Can set configuration on a user (PAT)' { + # $params = @{ + # Name = 'Octocat' + # Email = 'psmodule@psmodule.io' + # Blog = 'https://marius-storhaug.com' + # TwitterUsername = 'MariusStorhaug123' + # Company = 'PSModule' + # Location = 'USA' + # Hireable = $true + # Bio = 'I love programming' + # } + # { Set-GitHubUser @params } | Should -Not -Throw $user = Get-GitHubUser - $params = @{ - Name = 'Octocat' - Email = 'psmodule@psmodule.io' - Blog = 'https://marius-storhaug.com' - TwitterUsername = 'MariusStorhaug123' - Company = 'PSModule' - Location = 'USA' - Hireable = $true - Bio = 'I love programming' - } - { Set-GitHubUser @params } | Should -Not -Throw + { Set-GitHubUser -Name 'Octocat' } | Should -Not -Throw + { Set-GitHubUser -Email 'psmodule@psmodule.io' } | Should -Not -Throw + { Set-GitHubUser -Blog 'https://marius-storhaug.com' } | Should -Not -Throw + { Set-GitHubUser -TwitterUsername 'MariusStorhaug123' } | Should -Not -Throw + { Set-GitHubUser -Company 'PSModule' } | Should -Not -Throw + { Set-GitHubUser -Location 'USA' } | Should -Not -Throw + { Set-GitHubUser -Hireable $true } | Should -Not -Throw + { Set-GitHubUser -Bio 'I love programming' } | Should -Not -Throw $tmpUser = Get-GitHubUser $tmpUser.Name | Should -Be 'Octocat' $tmpUser.Email | Should -Be 'psmodule@psmodule.io' @@ -687,17 +727,25 @@ Describe 'As a user - Classic PAT token (PAT)' { $tmpUser.Location | Should -Be 'USA' $tmpUser.Hireable | Should -Be $true $tmpUser.Bio | Should -Be 'I love programming' - $user = @{ - Name = $user.Name - Email = $user.Email - Blog = $user.Blog - TwitterUsername = $user.TwitterUsername - Company = $user.Company - Location = $user.Location - Hireable = $user.Hireable - Bio = $user.Bio - } - Set-GitHubUser @user + { Set-GitHubUser -Name $user.Name } | Should -Not -Throw + { Set-GitHubUser -Email $user.Email } | Should -Not -Throw + { Set-GitHubUser -Blog $user.Blog } | Should -Not -Throw + { Set-GitHubUser -TwitterUsername $user.TwitterUsername } | Should -Not -Throw + { Set-GitHubUser -Company $user.Company } | Should -Not -Throw + { Set-GitHubUser -Location $user.Location } | Should -Not -Throw + { Set-GitHubUser -Hireable $user.Hireable } | Should -Not -Throw + { Set-GitHubUser -Bio $user.Bio } | Should -Not -Throw + # $user = @{ + # Name = $user.Name + # Email = $user.Email + # Blog = $user.Blog + # TwitterUsername = $user.TwitterUsername + # Company = $user.Company + # Location = $user.Location + # Hireable = $user.Hireable + # Bio = $user.Bio + # } + # Set-GitHubUser @user } } } From 89a9cb6952abfa0f3aef86c245ea03be7c21c6ab Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Wed, 25 Dec 2024 21:06:13 +0100 Subject: [PATCH 09/16] test --- tests/GitHub.Tests.ps1 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index 43d59e5ca..3380c8fe8 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -364,7 +364,7 @@ Describe 'As a user - Fine-grained PAT token - user account access (USER_FG_PAT) It 'Get-GitHubUser - Can set configuration on a user (USER_FG_PAT)' { # $params = @{ # Name = 'Octocat' - # Email = 'psmodule@psmodule.io' + # Email = 'Marius.Storhaug@outlook.com' # Blog = 'https://marius-storhaug.com' # TwitterUsername = 'MariusStorhaug123' # Company = 'PSModule' @@ -375,7 +375,7 @@ Describe 'As a user - Fine-grained PAT token - user account access (USER_FG_PAT) # { Set-GitHubUser @params } | Should -Not -Throw $user = Get-GitHubUser { Set-GitHubUser -Name 'Octocat' } | Should -Not -Throw - { Set-GitHubUser -Email 'psmodule@psmodule.io' } | Should -Not -Throw + { Set-GitHubUser -Email 'Marius.Storhaug@outlook.com' } | Should -Not -Throw { Set-GitHubUser -Blog 'https://marius-storhaug.com' } | Should -Not -Throw { Set-GitHubUser -TwitterUsername 'MariusStorhaug123' } | Should -Not -Throw { Set-GitHubUser -Company 'PSModule' } | Should -Not -Throw @@ -384,7 +384,7 @@ Describe 'As a user - Fine-grained PAT token - user account access (USER_FG_PAT) { Set-GitHubUser -Bio 'I love programming' } | Should -Not -Throw $tmpUser = Get-GitHubUser $tmpUser.Name | Should -Be 'Octocat' - $tmpUser.Email | Should -Be 'psmodule@psmodule.io' + $tmpUser.Email | Should -Be 'Marius.Storhaug@outlook.com' $tmpUser.Blog | Should -Be 'https://marius-storhaug.com' $tmpUser.TwitterUsername | Should -Be 'MariusStorhaug123' $tmpUser.Company | Should -Be 'PSModule' @@ -542,7 +542,7 @@ Describe 'As a user - Fine-grained PAT token - organization account access (ORG_ It 'Get-GitHubUser - Can set configuration on a user (ORG_FG_PAT)' { # $params = @{ # Name = 'Octocat' - # Email = 'psmodule@psmodule.io' + # Email = 'Marius.Storhaug@outlook.com' # Blog = 'https://marius-storhaug.com' # TwitterUsername = 'MariusStorhaug123' # Company = 'PSModule' @@ -553,7 +553,7 @@ Describe 'As a user - Fine-grained PAT token - organization account access (ORG_ # { Set-GitHubUser @params } | Should -Not -Throw $user = Get-GitHubUser { Set-GitHubUser -Name 'Octocat' } | Should -Not -Throw - { Set-GitHubUser -Email 'psmodule@psmodule.io' } | Should -Not -Throw + { Set-GitHubUser -Email 'Marius.Storhaug@outlook.com' } | Should -Not -Throw { Set-GitHubUser -Blog 'https://marius-storhaug.com' } | Should -Not -Throw { Set-GitHubUser -TwitterUsername 'MariusStorhaug123' } | Should -Not -Throw { Set-GitHubUser -Company 'PSModule' } | Should -Not -Throw @@ -562,7 +562,7 @@ Describe 'As a user - Fine-grained PAT token - organization account access (ORG_ { Set-GitHubUser -Bio 'I love programming' } | Should -Not -Throw $tmpUser = Get-GitHubUser $tmpUser.Name | Should -Be 'Octocat' - $tmpUser.Email | Should -Be 'psmodule@psmodule.io' + $tmpUser.Email | Should -Be 'Marius.Storhaug@outlook.com' $tmpUser.Blog | Should -Be 'https://marius-storhaug.com' $tmpUser.TwitterUsername | Should -Be 'MariusStorhaug123' $tmpUser.Company | Should -Be 'PSModule' @@ -700,7 +700,7 @@ Describe 'As a user - Classic PAT token (PAT)' { It 'Get-GitHubUser - Can set configuration on a user (PAT)' { # $params = @{ # Name = 'Octocat' - # Email = 'psmodule@psmodule.io' + # Email = 'Marius.Storhaug@outlook.com' # Blog = 'https://marius-storhaug.com' # TwitterUsername = 'MariusStorhaug123' # Company = 'PSModule' @@ -711,7 +711,7 @@ Describe 'As a user - Classic PAT token (PAT)' { # { Set-GitHubUser @params } | Should -Not -Throw $user = Get-GitHubUser { Set-GitHubUser -Name 'Octocat' } | Should -Not -Throw - { Set-GitHubUser -Email 'psmodule@psmodule.io' } | Should -Not -Throw + { Set-GitHubUser -Email 'Marius.Storhaug@outlook.com' } | Should -Not -Throw { Set-GitHubUser -Blog 'https://marius-storhaug.com' } | Should -Not -Throw { Set-GitHubUser -TwitterUsername 'MariusStorhaug123' } | Should -Not -Throw { Set-GitHubUser -Company 'PSModule' } | Should -Not -Throw @@ -720,7 +720,7 @@ Describe 'As a user - Classic PAT token (PAT)' { { Set-GitHubUser -Bio 'I love programming' } | Should -Not -Throw $tmpUser = Get-GitHubUser $tmpUser.Name | Should -Be 'Octocat' - $tmpUser.Email | Should -Be 'psmodule@psmodule.io' + $tmpUser.Email | Should -Be 'Marius.Storhaug@outlook.com' $tmpUser.Blog | Should -Be 'https://marius-storhaug.com' $tmpUser.TwitterUsername | Should -Be 'MariusStorhaug123' $tmpUser.Company | Should -Be 'PSModule' From f41c8432c1798a298699b4edb39e23124390b20e Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Wed, 25 Dec 2024 21:41:34 +0100 Subject: [PATCH 10/16] Remove email assertions from user configuration tests for privacy compliance --- tests/GitHub.Tests.ps1 | 9 --------- 1 file changed, 9 deletions(-) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index 3380c8fe8..aab72caed 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -364,7 +364,6 @@ Describe 'As a user - Fine-grained PAT token - user account access (USER_FG_PAT) It 'Get-GitHubUser - Can set configuration on a user (USER_FG_PAT)' { # $params = @{ # Name = 'Octocat' - # Email = 'Marius.Storhaug@outlook.com' # Blog = 'https://marius-storhaug.com' # TwitterUsername = 'MariusStorhaug123' # Company = 'PSModule' @@ -375,7 +374,6 @@ Describe 'As a user - Fine-grained PAT token - user account access (USER_FG_PAT) # { Set-GitHubUser @params } | Should -Not -Throw $user = Get-GitHubUser { Set-GitHubUser -Name 'Octocat' } | Should -Not -Throw - { Set-GitHubUser -Email 'Marius.Storhaug@outlook.com' } | Should -Not -Throw { Set-GitHubUser -Blog 'https://marius-storhaug.com' } | Should -Not -Throw { Set-GitHubUser -TwitterUsername 'MariusStorhaug123' } | Should -Not -Throw { Set-GitHubUser -Company 'PSModule' } | Should -Not -Throw @@ -384,7 +382,6 @@ Describe 'As a user - Fine-grained PAT token - user account access (USER_FG_PAT) { Set-GitHubUser -Bio 'I love programming' } | Should -Not -Throw $tmpUser = Get-GitHubUser $tmpUser.Name | Should -Be 'Octocat' - $tmpUser.Email | Should -Be 'Marius.Storhaug@outlook.com' $tmpUser.Blog | Should -Be 'https://marius-storhaug.com' $tmpUser.TwitterUsername | Should -Be 'MariusStorhaug123' $tmpUser.Company | Should -Be 'PSModule' @@ -542,7 +539,6 @@ Describe 'As a user - Fine-grained PAT token - organization account access (ORG_ It 'Get-GitHubUser - Can set configuration on a user (ORG_FG_PAT)' { # $params = @{ # Name = 'Octocat' - # Email = 'Marius.Storhaug@outlook.com' # Blog = 'https://marius-storhaug.com' # TwitterUsername = 'MariusStorhaug123' # Company = 'PSModule' @@ -553,7 +549,6 @@ Describe 'As a user - Fine-grained PAT token - organization account access (ORG_ # { Set-GitHubUser @params } | Should -Not -Throw $user = Get-GitHubUser { Set-GitHubUser -Name 'Octocat' } | Should -Not -Throw - { Set-GitHubUser -Email 'Marius.Storhaug@outlook.com' } | Should -Not -Throw { Set-GitHubUser -Blog 'https://marius-storhaug.com' } | Should -Not -Throw { Set-GitHubUser -TwitterUsername 'MariusStorhaug123' } | Should -Not -Throw { Set-GitHubUser -Company 'PSModule' } | Should -Not -Throw @@ -562,7 +557,6 @@ Describe 'As a user - Fine-grained PAT token - organization account access (ORG_ { Set-GitHubUser -Bio 'I love programming' } | Should -Not -Throw $tmpUser = Get-GitHubUser $tmpUser.Name | Should -Be 'Octocat' - $tmpUser.Email | Should -Be 'Marius.Storhaug@outlook.com' $tmpUser.Blog | Should -Be 'https://marius-storhaug.com' $tmpUser.TwitterUsername | Should -Be 'MariusStorhaug123' $tmpUser.Company | Should -Be 'PSModule' @@ -700,7 +694,6 @@ Describe 'As a user - Classic PAT token (PAT)' { It 'Get-GitHubUser - Can set configuration on a user (PAT)' { # $params = @{ # Name = 'Octocat' - # Email = 'Marius.Storhaug@outlook.com' # Blog = 'https://marius-storhaug.com' # TwitterUsername = 'MariusStorhaug123' # Company = 'PSModule' @@ -711,7 +704,6 @@ Describe 'As a user - Classic PAT token (PAT)' { # { Set-GitHubUser @params } | Should -Not -Throw $user = Get-GitHubUser { Set-GitHubUser -Name 'Octocat' } | Should -Not -Throw - { Set-GitHubUser -Email 'Marius.Storhaug@outlook.com' } | Should -Not -Throw { Set-GitHubUser -Blog 'https://marius-storhaug.com' } | Should -Not -Throw { Set-GitHubUser -TwitterUsername 'MariusStorhaug123' } | Should -Not -Throw { Set-GitHubUser -Company 'PSModule' } | Should -Not -Throw @@ -720,7 +712,6 @@ Describe 'As a user - Classic PAT token (PAT)' { { Set-GitHubUser -Bio 'I love programming' } | Should -Not -Throw $tmpUser = Get-GitHubUser $tmpUser.Name | Should -Be 'Octocat' - $tmpUser.Email | Should -Be 'Marius.Storhaug@outlook.com' $tmpUser.Blog | Should -Be 'https://marius-storhaug.com' $tmpUser.TwitterUsername | Should -Be 'MariusStorhaug123' $tmpUser.Company | Should -Be 'PSModule' From 384dec2c42b64fb4deb24fa2ab722483945d327d Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Wed, 25 Dec 2024 21:43:58 +0100 Subject: [PATCH 11/16] Fix --- src/functions/public/Users/Set-GitHubUser.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/src/functions/public/Users/Set-GitHubUser.ps1 b/src/functions/public/Users/Set-GitHubUser.ps1 index b7c23432e..1141ee744 100644 --- a/src/functions/public/Users/Set-GitHubUser.ps1 +++ b/src/functions/public/Users/Set-GitHubUser.ps1 @@ -87,6 +87,7 @@ hireable = $Hireable bio = $Bio } + $body | Remove-HashtableEntry -NullOrEmptyValues $inputObject = @{ Context = $Context From 799598a99b53a8fe75958c07b3d8197fdd49f7d3 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Thu, 26 Dec 2024 10:00:00 +0100 Subject: [PATCH 12/16] Fix casing of user properties in GitHub user tests for consistency --- tests/GitHub.Tests.ps1 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index aab72caed..3bd72eb08 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -361,7 +361,7 @@ Describe 'As a user - Fine-grained PAT token - user account access (USER_FG_PAT) It 'Get-GitHubUser - Get the specified user (USER_FG_PAT)' { { Get-GitHubUser -Username 'Octocat' } | Should -Not -Throw } - It 'Get-GitHubUser - Can set configuration on a user (USER_FG_PAT)' { + It 'Set-GitHubUser - Can set configuration on a user (USER_FG_PAT)' { # $params = @{ # Name = 'Octocat' # Blog = 'https://marius-storhaug.com' @@ -536,7 +536,7 @@ Describe 'As a user - Fine-grained PAT token - organization account access (ORG_ It 'Get-GitHubUser - Get the specified user (ORG_FG_PAT)' { { Get-GitHubUser -Username 'Octocat' } | Should -Not -Throw } - It 'Get-GitHubUser - Can set configuration on a user (ORG_FG_PAT)' { + It 'Set-GitHubUser - Can set configuration on a user (ORG_FG_PAT)' { # $params = @{ # Name = 'Octocat' # Blog = 'https://marius-storhaug.com' @@ -691,7 +691,7 @@ Describe 'As a user - Classic PAT token (PAT)' { It 'Get-GitHubUser - Get the specified user (PAT)' { { Get-GitHubUser -Username 'Octocat' } | Should -Not -Throw } - It 'Get-GitHubUser - Can set configuration on a user (PAT)' { + It 'Set-GitHubUser - Can set configuration on a user (PAT)' { # $params = @{ # Name = 'Octocat' # Blog = 'https://marius-storhaug.com' @@ -713,11 +713,11 @@ Describe 'As a user - Classic PAT token (PAT)' { $tmpUser = Get-GitHubUser $tmpUser.Name | Should -Be 'Octocat' $tmpUser.Blog | Should -Be 'https://marius-storhaug.com' - $tmpUser.TwitterUsername | Should -Be 'MariusStorhaug123' + $tmpUser.twitter_username | Should -Be 'MariusStorhaug123' $tmpUser.Company | Should -Be 'PSModule' - $tmpUser.Location | Should -Be 'USA' - $tmpUser.Hireable | Should -Be $true - $tmpUser.Bio | Should -Be 'I love programming' + $tmpUser.location | Should -Be 'USA' + $tmpUser.hireable | Should -Be $true + $tmpUser.bio | Should -Be 'I love programming' { Set-GitHubUser -Name $user.Name } | Should -Not -Throw { Set-GitHubUser -Email $user.Email } | Should -Not -Throw { Set-GitHubUser -Blog $user.Blog } | Should -Not -Throw From 9f404cb4f17e8fb71f7a6be5fe9fd3d339513416 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Thu, 26 Dec 2024 10:32:55 +0100 Subject: [PATCH 13/16] Fix casing of TwitterUsername property in GitHub user tests for consistency --- tests/GitHub.Tests.ps1 | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index 3bd72eb08..5736d8361 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -361,7 +361,7 @@ Describe 'As a user - Fine-grained PAT token - user account access (USER_FG_PAT) It 'Get-GitHubUser - Get the specified user (USER_FG_PAT)' { { Get-GitHubUser -Username 'Octocat' } | Should -Not -Throw } - It 'Set-GitHubUser - Can set configuration on a user (USER_FG_PAT)' { + It 'Get-GitHubUser - Can set configuration on a user (USER_FG_PAT)' { # $params = @{ # Name = 'Octocat' # Blog = 'https://marius-storhaug.com' @@ -383,7 +383,7 @@ Describe 'As a user - Fine-grained PAT token - user account access (USER_FG_PAT) $tmpUser = Get-GitHubUser $tmpUser.Name | Should -Be 'Octocat' $tmpUser.Blog | Should -Be 'https://marius-storhaug.com' - $tmpUser.TwitterUsername | Should -Be 'MariusStorhaug123' + $tmpUser.twitter_username | Should -Be 'MariusStorhaug123' $tmpUser.Company | Should -Be 'PSModule' $tmpUser.Location | Should -Be 'USA' $tmpUser.Hireable | Should -Be $true @@ -391,7 +391,7 @@ Describe 'As a user - Fine-grained PAT token - user account access (USER_FG_PAT) { Set-GitHubUser -Name $user.Name } | Should -Not -Throw { Set-GitHubUser -Email $user.Email } | Should -Not -Throw { Set-GitHubUser -Blog $user.Blog } | Should -Not -Throw - { Set-GitHubUser -TwitterUsername $user.TwitterUsername } | Should -Not -Throw + { Set-GitHubUser -TwitterUsername $user.twitter_username } | Should -Not -Throw { Set-GitHubUser -Company $user.Company } | Should -Not -Throw { Set-GitHubUser -Location $user.Location } | Should -Not -Throw { Set-GitHubUser -Hireable $user.Hireable } | Should -Not -Throw @@ -400,7 +400,7 @@ Describe 'As a user - Fine-grained PAT token - user account access (USER_FG_PAT) # Name = $user.Name # Email = $user.Email # Blog = $user.Blog - # TwitterUsername = $user.TwitterUsername + # TwitterUsername = $user.twitter_username # Company = $user.Company # Location = $user.Location # Hireable = $user.Hireable @@ -536,7 +536,7 @@ Describe 'As a user - Fine-grained PAT token - organization account access (ORG_ It 'Get-GitHubUser - Get the specified user (ORG_FG_PAT)' { { Get-GitHubUser -Username 'Octocat' } | Should -Not -Throw } - It 'Set-GitHubUser - Can set configuration on a user (ORG_FG_PAT)' { + It 'Get-GitHubUser - Can set configuration on a user (ORG_FG_PAT)' { # $params = @{ # Name = 'Octocat' # Blog = 'https://marius-storhaug.com' @@ -558,7 +558,7 @@ Describe 'As a user - Fine-grained PAT token - organization account access (ORG_ $tmpUser = Get-GitHubUser $tmpUser.Name | Should -Be 'Octocat' $tmpUser.Blog | Should -Be 'https://marius-storhaug.com' - $tmpUser.TwitterUsername | Should -Be 'MariusStorhaug123' + $tmpUser.twitter_username | Should -Be 'MariusStorhaug123' $tmpUser.Company | Should -Be 'PSModule' $tmpUser.Location | Should -Be 'USA' $tmpUser.Hireable | Should -Be $true @@ -566,7 +566,7 @@ Describe 'As a user - Fine-grained PAT token - organization account access (ORG_ { Set-GitHubUser -Name $user.Name } | Should -Not -Throw { Set-GitHubUser -Email $user.Email } | Should -Not -Throw { Set-GitHubUser -Blog $user.Blog } | Should -Not -Throw - { Set-GitHubUser -TwitterUsername $user.TwitterUsername } | Should -Not -Throw + { Set-GitHubUser -TwitterUsername $user.twitter_username } | Should -Not -Throw { Set-GitHubUser -Company $user.Company } | Should -Not -Throw { Set-GitHubUser -Location $user.Location } | Should -Not -Throw { Set-GitHubUser -Hireable $user.Hireable } | Should -Not -Throw @@ -575,7 +575,7 @@ Describe 'As a user - Fine-grained PAT token - organization account access (ORG_ # Name = $user.Name # Email = $user.Email # Blog = $user.Blog - # TwitterUsername = $user.TwitterUsername + # TwitterUsername = $user.twitter_username # Company = $user.Company # Location = $user.Location # Hireable = $user.Hireable @@ -691,7 +691,7 @@ Describe 'As a user - Classic PAT token (PAT)' { It 'Get-GitHubUser - Get the specified user (PAT)' { { Get-GitHubUser -Username 'Octocat' } | Should -Not -Throw } - It 'Set-GitHubUser - Can set configuration on a user (PAT)' { + It 'Get-GitHubUser - Can set configuration on a user (PAT)' { # $params = @{ # Name = 'Octocat' # Blog = 'https://marius-storhaug.com' @@ -721,7 +721,7 @@ Describe 'As a user - Classic PAT token (PAT)' { { Set-GitHubUser -Name $user.Name } | Should -Not -Throw { Set-GitHubUser -Email $user.Email } | Should -Not -Throw { Set-GitHubUser -Blog $user.Blog } | Should -Not -Throw - { Set-GitHubUser -TwitterUsername $user.TwitterUsername } | Should -Not -Throw + { Set-GitHubUser -TwitterUsername $user.twitter_username } | Should -Not -Throw { Set-GitHubUser -Company $user.Company } | Should -Not -Throw { Set-GitHubUser -Location $user.Location } | Should -Not -Throw { Set-GitHubUser -Hireable $user.Hireable } | Should -Not -Throw @@ -730,7 +730,7 @@ Describe 'As a user - Classic PAT token (PAT)' { # Name = $user.Name # Email = $user.Email # Blog = $user.Blog - # TwitterUsername = $user.TwitterUsername + # TwitterUsername = $user.twitter_username # Company = $user.Company # Location = $user.Location # Hireable = $user.Hireable From d3338a9efbe26cc891de9e24e85fe838834544e2 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Thu, 26 Dec 2024 10:36:08 +0100 Subject: [PATCH 14/16] Normalize casing of user properties in GitHub user tests for consistency --- tests/GitHub.Tests.ps1 | 108 +++++++++++++++++++---------------------- 1 file changed, 51 insertions(+), 57 deletions(-) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index 5736d8361..57cd2b9ed 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -381,30 +381,28 @@ Describe 'As a user - Fine-grained PAT token - user account access (USER_FG_PAT) { Set-GitHubUser -Hireable $true } | Should -Not -Throw { Set-GitHubUser -Bio 'I love programming' } | Should -Not -Throw $tmpUser = Get-GitHubUser - $tmpUser.Name | Should -Be 'Octocat' - $tmpUser.Blog | Should -Be 'https://marius-storhaug.com' + $tmpUser.name | Should -Be 'Octocat' + $tmpUser.blog | Should -Be 'https://marius-storhaug.com' $tmpUser.twitter_username | Should -Be 'MariusStorhaug123' - $tmpUser.Company | Should -Be 'PSModule' - $tmpUser.Location | Should -Be 'USA' - $tmpUser.Hireable | Should -Be $true - $tmpUser.Bio | Should -Be 'I love programming' - { Set-GitHubUser -Name $user.Name } | Should -Not -Throw - { Set-GitHubUser -Email $user.Email } | Should -Not -Throw - { Set-GitHubUser -Blog $user.Blog } | Should -Not -Throw + $tmpUser.company | Should -Be 'PSModule' + $tmpUser.location | Should -Be 'USA' + $tmpUser.hireable | Should -Be $true + $tmpUser.bio | Should -Be 'I love programming' + { Set-GitHubUser -Name $user.name } | Should -Not -Throw + { Set-GitHubUser -Blog $user.blog } | Should -Not -Throw { Set-GitHubUser -TwitterUsername $user.twitter_username } | Should -Not -Throw - { Set-GitHubUser -Company $user.Company } | Should -Not -Throw - { Set-GitHubUser -Location $user.Location } | Should -Not -Throw - { Set-GitHubUser -Hireable $user.Hireable } | Should -Not -Throw - { Set-GitHubUser -Bio $user.Bio } | Should -Not -Throw + { Set-GitHubUser -Company $user.company } | Should -Not -Throw + { Set-GitHubUser -Location $user.location } | Should -Not -Throw + { Set-GitHubUser -Hireable $user.hireable } | Should -Not -Throw + { Set-GitHubUser -Bio $user.bio } | Should -Not -Throw # $user = @{ - # Name = $user.Name - # Email = $user.Email - # Blog = $user.Blog + # Name = $user.name + # Blog = $user.blog # TwitterUsername = $user.twitter_username - # Company = $user.Company - # Location = $user.Location - # Hireable = $user.Hireable - # Bio = $user.Bio + # Company = $user.company + # Location = $user.location + # Hireable = $user.hireable + # Bio = $user.bio # } # Set-GitHubUser @user } @@ -556,30 +554,28 @@ Describe 'As a user - Fine-grained PAT token - organization account access (ORG_ { Set-GitHubUser -Hireable $true } | Should -Not -Throw { Set-GitHubUser -Bio 'I love programming' } | Should -Not -Throw $tmpUser = Get-GitHubUser - $tmpUser.Name | Should -Be 'Octocat' - $tmpUser.Blog | Should -Be 'https://marius-storhaug.com' + $tmpUser.name | Should -Be 'Octocat' + $tmpUser.blog | Should -Be 'https://marius-storhaug.com' $tmpUser.twitter_username | Should -Be 'MariusStorhaug123' - $tmpUser.Company | Should -Be 'PSModule' - $tmpUser.Location | Should -Be 'USA' - $tmpUser.Hireable | Should -Be $true - $tmpUser.Bio | Should -Be 'I love programming' - { Set-GitHubUser -Name $user.Name } | Should -Not -Throw - { Set-GitHubUser -Email $user.Email } | Should -Not -Throw - { Set-GitHubUser -Blog $user.Blog } | Should -Not -Throw + $tmpUser.company | Should -Be 'PSModule' + $tmpUser.location | Should -Be 'USA' + $tmpUser.hireable | Should -Be $true + $tmpUser.bio | Should -Be 'I love programming' + { Set-GitHubUser -Name $user.name } | Should -Not -Throw + { Set-GitHubUser -Blog $user.blog } | Should -Not -Throw { Set-GitHubUser -TwitterUsername $user.twitter_username } | Should -Not -Throw - { Set-GitHubUser -Company $user.Company } | Should -Not -Throw - { Set-GitHubUser -Location $user.Location } | Should -Not -Throw - { Set-GitHubUser -Hireable $user.Hireable } | Should -Not -Throw - { Set-GitHubUser -Bio $user.Bio } | Should -Not -Throw + { Set-GitHubUser -Company $user.company } | Should -Not -Throw + { Set-GitHubUser -Location $user.location } | Should -Not -Throw + { Set-GitHubUser -Hireable $user.hireable } | Should -Not -Throw + { Set-GitHubUser -Bio $user.bio } | Should -Not -Throw # $user = @{ - # Name = $user.Name - # Email = $user.Email - # Blog = $user.Blog + # Name = $user.name + # Blog = $user.blog # TwitterUsername = $user.twitter_username - # Company = $user.Company - # Location = $user.Location - # Hireable = $user.Hireable - # Bio = $user.Bio + # Company = $user.company + # Location = $user.location + # Hireable = $user.hireable + # Bio = $user.bio # } # Set-GitHubUser @user } @@ -711,30 +707,28 @@ Describe 'As a user - Classic PAT token (PAT)' { { Set-GitHubUser -Hireable $true } | Should -Not -Throw { Set-GitHubUser -Bio 'I love programming' } | Should -Not -Throw $tmpUser = Get-GitHubUser - $tmpUser.Name | Should -Be 'Octocat' - $tmpUser.Blog | Should -Be 'https://marius-storhaug.com' + $tmpUser.name | Should -Be 'Octocat' + $tmpUser.blog | Should -Be 'https://marius-storhaug.com' $tmpUser.twitter_username | Should -Be 'MariusStorhaug123' - $tmpUser.Company | Should -Be 'PSModule' + $tmpUser.company | Should -Be 'PSModule' $tmpUser.location | Should -Be 'USA' $tmpUser.hireable | Should -Be $true $tmpUser.bio | Should -Be 'I love programming' - { Set-GitHubUser -Name $user.Name } | Should -Not -Throw - { Set-GitHubUser -Email $user.Email } | Should -Not -Throw - { Set-GitHubUser -Blog $user.Blog } | Should -Not -Throw + { Set-GitHubUser -Name $user.name } | Should -Not -Throw + { Set-GitHubUser -Blog $user.blog } | Should -Not -Throw { Set-GitHubUser -TwitterUsername $user.twitter_username } | Should -Not -Throw - { Set-GitHubUser -Company $user.Company } | Should -Not -Throw - { Set-GitHubUser -Location $user.Location } | Should -Not -Throw - { Set-GitHubUser -Hireable $user.Hireable } | Should -Not -Throw - { Set-GitHubUser -Bio $user.Bio } | Should -Not -Throw + { Set-GitHubUser -Company $user.company } | Should -Not -Throw + { Set-GitHubUser -Location $user.location } | Should -Not -Throw + { Set-GitHubUser -Hireable $user.hireable } | Should -Not -Throw + { Set-GitHubUser -Bio $user.bio } | Should -Not -Throw # $user = @{ - # Name = $user.Name - # Email = $user.Email - # Blog = $user.Blog + # Name = $user.name + # Blog = $user.blog # TwitterUsername = $user.twitter_username - # Company = $user.Company - # Location = $user.Location - # Hireable = $user.Hireable - # Bio = $user.Bio + # Company = $user.company + # Location = $user.location + # Hireable = $user.hireable + # Bio = $user.bio # } # Set-GitHubUser @user } From 941887882305cb8cd2e36add8b82ae18bdc3f578 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Thu, 26 Dec 2024 12:18:59 +0100 Subject: [PATCH 15/16] Fix --- tests/GitHub.Tests.ps1 | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index 57cd2b9ed..02772aaa8 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -368,7 +368,6 @@ Describe 'As a user - Fine-grained PAT token - user account access (USER_FG_PAT) # TwitterUsername = 'MariusStorhaug123' # Company = 'PSModule' # Location = 'USA' - # Hireable = $true # Bio = 'I love programming' # } # { Set-GitHubUser @params } | Should -Not -Throw @@ -378,7 +377,6 @@ Describe 'As a user - Fine-grained PAT token - user account access (USER_FG_PAT) { Set-GitHubUser -TwitterUsername 'MariusStorhaug123' } | Should -Not -Throw { Set-GitHubUser -Company 'PSModule' } | Should -Not -Throw { Set-GitHubUser -Location 'USA' } | Should -Not -Throw - { Set-GitHubUser -Hireable $true } | Should -Not -Throw { Set-GitHubUser -Bio 'I love programming' } | Should -Not -Throw $tmpUser = Get-GitHubUser $tmpUser.name | Should -Be 'Octocat' @@ -386,14 +384,12 @@ Describe 'As a user - Fine-grained PAT token - user account access (USER_FG_PAT) $tmpUser.twitter_username | Should -Be 'MariusStorhaug123' $tmpUser.company | Should -Be 'PSModule' $tmpUser.location | Should -Be 'USA' - $tmpUser.hireable | Should -Be $true $tmpUser.bio | Should -Be 'I love programming' { Set-GitHubUser -Name $user.name } | Should -Not -Throw { Set-GitHubUser -Blog $user.blog } | Should -Not -Throw { Set-GitHubUser -TwitterUsername $user.twitter_username } | Should -Not -Throw { Set-GitHubUser -Company $user.company } | Should -Not -Throw { Set-GitHubUser -Location $user.location } | Should -Not -Throw - { Set-GitHubUser -Hireable $user.hireable } | Should -Not -Throw { Set-GitHubUser -Bio $user.bio } | Should -Not -Throw # $user = @{ # Name = $user.name @@ -401,7 +397,6 @@ Describe 'As a user - Fine-grained PAT token - user account access (USER_FG_PAT) # TwitterUsername = $user.twitter_username # Company = $user.company # Location = $user.location - # Hireable = $user.hireable # Bio = $user.bio # } # Set-GitHubUser @user @@ -541,7 +536,6 @@ Describe 'As a user - Fine-grained PAT token - organization account access (ORG_ # TwitterUsername = 'MariusStorhaug123' # Company = 'PSModule' # Location = 'USA' - # Hireable = $true # Bio = 'I love programming' # } # { Set-GitHubUser @params } | Should -Not -Throw @@ -551,7 +545,6 @@ Describe 'As a user - Fine-grained PAT token - organization account access (ORG_ { Set-GitHubUser -TwitterUsername 'MariusStorhaug123' } | Should -Not -Throw { Set-GitHubUser -Company 'PSModule' } | Should -Not -Throw { Set-GitHubUser -Location 'USA' } | Should -Not -Throw - { Set-GitHubUser -Hireable $true } | Should -Not -Throw { Set-GitHubUser -Bio 'I love programming' } | Should -Not -Throw $tmpUser = Get-GitHubUser $tmpUser.name | Should -Be 'Octocat' @@ -559,14 +552,12 @@ Describe 'As a user - Fine-grained PAT token - organization account access (ORG_ $tmpUser.twitter_username | Should -Be 'MariusStorhaug123' $tmpUser.company | Should -Be 'PSModule' $tmpUser.location | Should -Be 'USA' - $tmpUser.hireable | Should -Be $true $tmpUser.bio | Should -Be 'I love programming' { Set-GitHubUser -Name $user.name } | Should -Not -Throw { Set-GitHubUser -Blog $user.blog } | Should -Not -Throw { Set-GitHubUser -TwitterUsername $user.twitter_username } | Should -Not -Throw { Set-GitHubUser -Company $user.company } | Should -Not -Throw { Set-GitHubUser -Location $user.location } | Should -Not -Throw - { Set-GitHubUser -Hireable $user.hireable } | Should -Not -Throw { Set-GitHubUser -Bio $user.bio } | Should -Not -Throw # $user = @{ # Name = $user.name @@ -574,7 +565,6 @@ Describe 'As a user - Fine-grained PAT token - organization account access (ORG_ # TwitterUsername = $user.twitter_username # Company = $user.company # Location = $user.location - # Hireable = $user.hireable # Bio = $user.bio # } # Set-GitHubUser @user @@ -694,7 +684,6 @@ Describe 'As a user - Classic PAT token (PAT)' { # TwitterUsername = 'MariusStorhaug123' # Company = 'PSModule' # Location = 'USA' - # Hireable = $true # Bio = 'I love programming' # } # { Set-GitHubUser @params } | Should -Not -Throw @@ -704,7 +693,6 @@ Describe 'As a user - Classic PAT token (PAT)' { { Set-GitHubUser -TwitterUsername 'MariusStorhaug123' } | Should -Not -Throw { Set-GitHubUser -Company 'PSModule' } | Should -Not -Throw { Set-GitHubUser -Location 'USA' } | Should -Not -Throw - { Set-GitHubUser -Hireable $true } | Should -Not -Throw { Set-GitHubUser -Bio 'I love programming' } | Should -Not -Throw $tmpUser = Get-GitHubUser $tmpUser.name | Should -Be 'Octocat' @@ -712,14 +700,12 @@ Describe 'As a user - Classic PAT token (PAT)' { $tmpUser.twitter_username | Should -Be 'MariusStorhaug123' $tmpUser.company | Should -Be 'PSModule' $tmpUser.location | Should -Be 'USA' - $tmpUser.hireable | Should -Be $true $tmpUser.bio | Should -Be 'I love programming' { Set-GitHubUser -Name $user.name } | Should -Not -Throw { Set-GitHubUser -Blog $user.blog } | Should -Not -Throw { Set-GitHubUser -TwitterUsername $user.twitter_username } | Should -Not -Throw { Set-GitHubUser -Company $user.company } | Should -Not -Throw { Set-GitHubUser -Location $user.location } | Should -Not -Throw - { Set-GitHubUser -Hireable $user.hireable } | Should -Not -Throw { Set-GitHubUser -Bio $user.bio } | Should -Not -Throw # $user = @{ # Name = $user.name @@ -727,7 +713,6 @@ Describe 'As a user - Classic PAT token (PAT)' { # TwitterUsername = $user.twitter_username # Company = $user.company # Location = $user.location - # Hireable = $user.hireable # Bio = $user.bio # } # Set-GitHubUser @user From d6ddca323bfb7ad79c4fdd3bd705dc8eaae7796e Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Thu, 26 Dec 2024 13:15:41 +0100 Subject: [PATCH 16/16] Get user removal --- tests/GitHub.Tests.ps1 | 50 ------------------------------------------ 1 file changed, 50 deletions(-) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index 02772aaa8..8abf828ea 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -529,46 +529,6 @@ Describe 'As a user - Fine-grained PAT token - organization account access (ORG_ It 'Get-GitHubUser - Get the specified user (ORG_FG_PAT)' { { Get-GitHubUser -Username 'Octocat' } | Should -Not -Throw } - It 'Get-GitHubUser - Can set configuration on a user (ORG_FG_PAT)' { - # $params = @{ - # Name = 'Octocat' - # Blog = 'https://marius-storhaug.com' - # TwitterUsername = 'MariusStorhaug123' - # Company = 'PSModule' - # Location = 'USA' - # Bio = 'I love programming' - # } - # { Set-GitHubUser @params } | Should -Not -Throw - $user = Get-GitHubUser - { Set-GitHubUser -Name 'Octocat' } | Should -Not -Throw - { Set-GitHubUser -Blog 'https://marius-storhaug.com' } | Should -Not -Throw - { Set-GitHubUser -TwitterUsername 'MariusStorhaug123' } | Should -Not -Throw - { Set-GitHubUser -Company 'PSModule' } | Should -Not -Throw - { Set-GitHubUser -Location 'USA' } | Should -Not -Throw - { Set-GitHubUser -Bio 'I love programming' } | Should -Not -Throw - $tmpUser = Get-GitHubUser - $tmpUser.name | Should -Be 'Octocat' - $tmpUser.blog | Should -Be 'https://marius-storhaug.com' - $tmpUser.twitter_username | Should -Be 'MariusStorhaug123' - $tmpUser.company | Should -Be 'PSModule' - $tmpUser.location | Should -Be 'USA' - $tmpUser.bio | Should -Be 'I love programming' - { Set-GitHubUser -Name $user.name } | Should -Not -Throw - { Set-GitHubUser -Blog $user.blog } | Should -Not -Throw - { Set-GitHubUser -TwitterUsername $user.twitter_username } | Should -Not -Throw - { Set-GitHubUser -Company $user.company } | Should -Not -Throw - { Set-GitHubUser -Location $user.location } | Should -Not -Throw - { Set-GitHubUser -Bio $user.bio } | Should -Not -Throw - # $user = @{ - # Name = $user.name - # Blog = $user.blog - # TwitterUsername = $user.twitter_username - # Company = $user.company - # Location = $user.location - # Bio = $user.bio - # } - # Set-GitHubUser @user - } } } @@ -843,11 +803,6 @@ Describe 'As a GitHub App - Enterprise (APP_ENT)' { AfterAll { Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount } - Context 'User' { - It 'Can be called with Username parameter (APP_ENT)' { - { Get-GitHubUser -Username 'Octocat' } | Should -Not -Throw - } - } Context 'App' { It 'Can get the authenticated GitHubApp (APP_ENT)' { $app = Get-GitHubApp @@ -919,9 +874,4 @@ Describe 'As a GitHub App - Organization (APP_ORG)' { } | Should -Not -Throw } } - Context 'User' { - It 'Can be called with Username parameter (APP_ENT)' { - { Get-GitHubUser -Username 'Octocat' } | Should -Not -Throw - } - } }