Skip to content

Commit

Permalink
Run tests on Meta
Browse files Browse the repository at this point in the history
  • Loading branch information
MariusStorhaug committed Dec 9, 2024
1 parent 2d3e1bd commit 2f61d10
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 42 deletions.
25 changes: 17 additions & 8 deletions src/functions/public/Meta/Get-GitHubApiVersion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,25 @@
[object] $Context = (Get-GitHubContext)
)

$Context = Resolve-GitHubContext -Context $Context

$inputObject = @{
Context = $Context
ApiEndpoint = '/versions'
Method = 'GET'
begin {
$commandName = $MyInvocation.MyCommand.Name
Write-Verbose "[$commandName] - Start"
$Context = Resolve-GitHubContext -Context $Context
}

Invoke-GitHubAPI @inputObject | ForEach-Object {
Write-Output $_.Response
process {
$inputObject = @{
Context = $Context
ApiEndpoint = '/versions'
Method = 'GET'
}

Invoke-GitHubAPI @inputObject | ForEach-Object {
Write-Output $_.Response
}
}

end {
Write-Verbose "[$commandName] - End"
}
}
24 changes: 17 additions & 7 deletions src/functions/public/Meta/Get-GitHubMeta.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,25 @@
[object] $Context = (Get-GitHubContext)
)

$Context = Resolve-GitHubContext -Context $Context
begin {
$commandName = $MyInvocation.MyCommand.Name
Write-Verbose "[$commandName] - Start"
$Context = Resolve-GitHubContext -Context $Context
}

process {
$inputObject = @{
Context = $Context
ApiEndpoint = '/meta'
Method = 'GET'
}

$inputObject = @{
Context = $Context
ApiEndpoint = '/meta'
Method = 'GET'
Invoke-GitHubAPI @inputObject | ForEach-Object {
Write-Output $_.Response
}
}

Invoke-GitHubAPI @inputObject | ForEach-Object {
Write-Output $_.Response
end {
Write-Verbose "[$commandName] - End"
}
}
32 changes: 21 additions & 11 deletions src/functions/public/Meta/Get-GitHubOctocat.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,30 @@
[object] $Context = (Get-GitHubContext)
)

$Context = Resolve-GitHubContext -Context $Context

$body = @{
s = $S
begin {
$commandName = $MyInvocation.MyCommand.Name
Write-Verbose "[$commandName] - Start"
$Context = Resolve-GitHubContext -Context $Context
}

$inputObject = @{
Context = $Context
APIEndpoint = '/octocat'
Method = 'GET'
Body = $body
process {
$body = @{
s = $S
}

$inputObject = @{
Context = $Context
APIEndpoint = '/octocat'
Method = 'GET'
Body = $body
}

Invoke-GitHubAPI @inputObject | ForEach-Object {
Write-Output $_.Response
}
}

Invoke-GitHubAPI @inputObject | ForEach-Object {
Write-Output $_.Response
end {
Write-Verbose "[$commandName] - End"
}
}
25 changes: 17 additions & 8 deletions src/functions/public/Meta/Get-GitHubRoot.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,25 @@
[object] $Context = (Get-GitHubContext)
)

$Context = Resolve-GitHubContext -Context $Context

$inputObject = @{
Context = $Context
APIEndpoint = '/'
Method = 'GET'
begin {
$commandName = $MyInvocation.MyCommand.Name
Write-Verbose "[$commandName] - Start"
$Context = Resolve-GitHubContext -Context $Context
}

Invoke-GitHubAPI @inputObject | ForEach-Object {
Write-Output $_.Response
process {
$inputObject = @{
Context = $Context
APIEndpoint = '/'
Method = 'GET'
}

Invoke-GitHubAPI @inputObject | ForEach-Object {
Write-Output $_.Response
}
}

end {
Write-Verbose "[$commandName] - End"
}
}
24 changes: 17 additions & 7 deletions src/functions/public/Meta/Get-GitHubZen.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,25 @@
[object] $Context = (Get-GitHubContext)
)

$Context = Resolve-GitHubContext -Context $Context
begin {
$commandName = $MyInvocation.MyCommand.Name
Write-Verbose "[$commandName] - Start"
$Context = Resolve-GitHubContext -Context $Context
}

process {
$inputObject = @{
Context = $Context
APIEndpoint = '/zen'
Method = 'GET'
}

$inputObject = @{
Context = $Context
APIEndpoint = '/zen'
Method = 'GET'
Invoke-GitHubAPI @inputObject | ForEach-Object {
Write-Output $_.Response
}
}

Invoke-GitHubAPI @inputObject | ForEach-Object {
Write-Output $_.Response
end {
Write-Verbose "[$commandName] - End"
}
}
29 changes: 28 additions & 1 deletion tests/GitHub.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Describe 'GitHub' {

It 'Can connect to all GitHub App Installations' {
{ Connect-GitHubApp } | Should -Not -Throw
Write-Verbose "Default context:" -Verbose
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
Expand Down Expand Up @@ -111,6 +111,33 @@ Describe 'GitHub' {
$config.ID | Should -Be 'PSModule.GitHub'
}
}
Context 'Meta' {
It 'Get-GitHubRoot' {
$root = Get-GitHubRoot
Write-Verbose ($root | Format-Table | Out-String) -Verbose
$root | Should -Not -BeNullOrEmpty
}
It 'Get-GitHubApiVersion' {
$apiVersion = Get-GitHubApiVersion
Write-Verbose ($apiVersion | Format-Table | Out-String) -Verbose
$apiVersion | Should -Not -BeNullOrEmpty
}
It 'Get-GitHubMeta' {
$meta = Get-GitHubMeta
Write-Verbose ($meta | Format-Table | Out-String) -Verbose
$meta | Should -Not -BeNullOrEmpty
}
It 'Get-GitHubOctocat' {
$octocat = Get-GitHubOctocat
Write-Verbose ($octocat | Format-Table | Out-String) -Verbose
$octocat | Should -Not -BeNullOrEmpty
}
It 'Get-GitHubZen' {
$zen = Get-GitHubZen
Write-Verbose ($zen | Format-Table | Out-String) -Verbose
$zen | Should -Not -BeNullOrEmpty
}
}
Context 'Git' {
It 'Set-GitHubGitConfig sets the Git configuration' {
{ Set-GitHubGitConfig } | Should -Not -Throw
Expand Down

0 comments on commit 2f61d10

Please sign in to comment.