diff --git a/src/classes/public/Teams/GitHubTeam.ps1 b/src/classes/public/Teams/GitHubTeam.ps1
index d6dff9c09..07c56b209 100644
--- a/src/classes/public/Teams/GitHubTeam.ps1
+++ b/src/classes/public/Teams/GitHubTeam.ps1
@@ -14,6 +14,10 @@
# The description of the team.
[string] $Description
+ # The HTML URL of the team.
+ # Example: https://github.com/orgs/github/teams/justice-league
+ [string] $Url
+
# The notification setting the team has chosen.
# $true = notifications_enabled - team members receive notifications when the team is @mentioned.
# $false = notifications_disabled - no one receives notifications.
diff --git a/src/functions/private/Teams/Get-GitHubTeamBySlug.ps1 b/src/functions/private/Teams/Get-GitHubTeamBySlug.ps1
index b72a5067e..2860a655a 100644
--- a/src/functions/private/Teams/Get-GitHubTeamBySlug.ps1
+++ b/src/functions/private/Teams/Get-GitHubTeamBySlug.ps1
@@ -13,16 +13,15 @@
[OutputType([GitHubTeam])]
[CmdletBinding()]
param(
- # The slug of the team name.
- [Parameter(Mandatory)]
- [Alias('team_slug')]
- [string] $Slug,
-
# The organization name. The name is not case sensitive.
# If not provided, the owner from the context will be used.
- [Parameter()]
+ [Parameter(Mandatory)]
[string] $Organization,
+ # The slug of the team name.
+ [Parameter(Mandatory)]
+ [string] $Slug,
+
# The context to run the command in. Used to get the details for the API call.
# Can be either a string or a GitHubContext object.
[Parameter(Mandatory)]
@@ -36,72 +35,63 @@
}
process {
- $query = @"
-query(`$org: String!, `$teamSlug: String!) {
- organization(login: `$org) {
- team(slug: `$teamSlug) {
- id
+ $inputObject = @{
+ Query = @'
+query($org: String!, $teamSlug: String!) {
+ organization(login: $org) {
+ team(slug: $teamSlug) {
+ id
+ name
+ slug
+ url
+ combinedSlug
+ databaseId
+ description
+ notificationSetting
+ privacy
+ parentTeam {
name
slug
- combinedSlug
- databaseId
- description
- notificationSetting
- privacy
- parentTeam {
+ }
+ childTeams(first: 100) {
+ nodes {
name
- slug
}
- organization {
- login
- }
- childTeams(first: 100) {
- nodes {
- name
- }
- }
- createdAt
- updatedAt
}
+ createdAt
+ updatedAt
}
}
}
-"@
-
- # Variables hash that will be sent with the query
- $variables = @{
- org = $Organization
- teamSlug = $Slug
+'@
+ Variables = @{
+ org = $Organization
+ teamSlug = $Slug
+ }
+ Context = $Context
}
-
- # Send the request to the GitHub GraphQL API
- $data = Invoke-GitHubGraphQLQuery -Query $query -Variables $variables -Context $Context
-
- # Extract team data
+ $data = Invoke-GitHubGraphQLQuery @inputObject
$team = $data.organization.team
-
- # Output the team object
- if (-not $team) {
- return
+ if ($team) {
+ [GitHubTeam](
+ @{
+ Name = $team.name
+ Slug = $team.slug
+ NodeID = $team.id
+ Url = $team.url
+ CombinedSlug = $team.CombinedSlug
+ ID = $team.DatabaseId
+ Description = $team.description
+ Notifications = $team.notificationSetting -eq 'NOTIFICATIONS_ENABLED' ? $true : $false
+ Visible = $team.privacy -eq 'VISIBLE' ? $true : $false
+ ParentTeam = $team.parentTeam.slug
+ Organization = $Organization
+ ChildTeams = $team.childTeams.nodes.name
+ CreatedAt = $team.createdAt
+ UpdatedAt = $team.updatedAt
+ }
+ )
}
-
- [GitHubTeam](
- @{
- Name = $team.name
- Slug = $team.slug
- NodeID = $team.id
- CombinedSlug = $team.CombinedSlug
- ID = $team.DatabaseId
- Description = $team.description
- Notifications = $team.notificationSetting -eq 'NOTIFICATIONS_ENABLED' ? $true : $false
- Visible = $team.privacy -eq 'VISIBLE' ? $true : $false
- ParentTeam = $team.parentTeam.slug
- Organization = $team.organization.login
- ChildTeams = $team.childTeams.nodes.name
- CreatedAt = $team.createdAt
- UpdatedAt = $team.updatedAt
- }
- )
}
end {
diff --git a/src/functions/private/Teams/Get-GitHubTeamListByOrg.ps1 b/src/functions/private/Teams/Get-GitHubTeamListByOrg.ps1
index ef1d7fca1..ba10d1e12 100644
--- a/src/functions/private/Teams/Get-GitHubTeamListByOrg.ps1
+++ b/src/functions/private/Teams/Get-GitHubTeamListByOrg.ps1
@@ -8,9 +8,6 @@
.EXAMPLE
Get-GitHubTeamListByOrg -Organization 'github'
-
- .NOTES
- [List teams](https://docs.github.com/rest/teams/teams#list-teams)
#>
[OutputType([GitHubTeam[]])]
[CmdletBinding()]
@@ -33,14 +30,16 @@
}
process {
- $query = @"
-query(`$org: String!, `$after: String) {
- organization(login: `$org) {
- teams(first: 100, after: `$after) {
+ $inputObject = @{
+ Query = @'
+query($org: String!, $after: String) {
+ organization(login: $org) {
+ teams(first: 100, after: $after) {
nodes {
id
name
slug
+ url
combinedSlug
databaseId
description
@@ -50,9 +49,6 @@ query(`$org: String!, `$after: String) {
name
slug
}
- organization {
- login
- }
childTeams(first: 100) {
nodes {
name
@@ -68,49 +64,40 @@ query(`$org: String!, `$after: String) {
}
}
}
-"@
-
- # Variables hash that will be sent with the query
- $variables = @{
- org = $Organization
+'@
+ Variables = @{
+ org = $Organization
+ }
+ Context = $Context
}
-
- # Prepare to store results and handle pagination
$hasNextPage = $true
$after = $null
do {
# Update the cursor for pagination
- $variables['after'] = $after
-
- # Send the request to the GitHub GraphQL API
- $data = Invoke-GitHubGraphQLQuery -Query $query -Variables $variables -Context $Context
-
- # Extract team data
+ $inputObject['Variables']['after'] = $after
+ $data = Invoke-GitHubGraphQLQuery @inputObject
$teams = $data.organization.teams
-
- # Accumulate the teams in results
$teams.nodes | ForEach-Object {
[GitHubTeam](
@{
Name = $_.name
Slug = $_.slug
NodeID = $_.id
+ Url = $_.url
CombinedSlug = $_.combinedSlug
ID = $_.databaseId
Description = $_.description
Notifications = $_.notificationSetting -eq 'NOTIFICATIONS_ENABLED' ? $true : $false
Visible = $_.privacy -eq 'VISIBLE' ? $true : $false
ParentTeam = $_.parentTeam.slug
- Organization = $_.organization.login
+ Organization = $Organization
ChildTeams = $_.childTeams.nodes.name
CreatedAt = $_.createdAt
UpdatedAt = $_.updatedAt
}
)
}
-
- # Check if there's another page to fetch
$hasNextPage = $teams.pageInfo.hasNextPage
$after = $teams.pageInfo.endCursor
} while ($hasNextPage)
diff --git a/src/functions/public/API/Invoke-GitHubAPI.ps1 b/src/functions/public/API/Invoke-GitHubAPI.ps1
index 22b98550b..0cf5d8996 100644
--- a/src/functions/public/API/Invoke-GitHubAPI.ps1
+++ b/src/functions/public/API/Invoke-GitHubAPI.ps1
@@ -315,15 +315,21 @@ filter Invoke-GitHubAPI {
Information = $errordetails.documentation_url
Status = $failure.Exception.Message
StatusCode = $errordetails.status
+ ErrorTime = Get-Date -Format 's'
}
- $APICall.HttpVersion = $APICall.HttpVersion.ToString()
- $APICall.Headers = $APICall.Headers | ConvertTo-Json
- $APICall.Method = $APICall.Method.ToString()
$exception = @"
----------------------------------
+Request:
+$([pscustomobject]$APICall | Format-List -Property Headers, HttpVersion, Method, Uri, ContentType, Authentication, Token | Out-String)
+----------------------------------
+Response Headers:
+$($headers | Format-List | Out-String)
+----------------------------------
+Error:
$($errorResult | Format-List | Out-String)
----------------------------------
+
"@
$PSCmdlet.ThrowTerminatingError(
[System.Management.Automation.ErrorRecord]::new(
diff --git a/src/functions/public/Repositories/Get-GitHubRepository.ps1 b/src/functions/public/Repositories/Get-GitHubRepository.ps1
index 19013936d..42f8ff8b4 100644
--- a/src/functions/public/Repositories/Get-GitHubRepository.ps1
+++ b/src/functions/public/Repositories/Get-GitHubRepository.ps1
@@ -26,7 +26,7 @@
Gets the repositories for the specified user.
.EXAMPLE
- Get-GitHubRepository -Owner 'github' -Name 'octocat'
+ Get-GitHubRepository -Organization 'github' -Name 'octocat'
Gets the specified repository.
diff --git a/src/functions/public/Teams/Get-GitHubTeam.ps1 b/src/functions/public/Teams/Get-GitHubTeam.ps1
index 6560786b1..6c692228e 100644
--- a/src/functions/public/Teams/Get-GitHubTeam.ps1
+++ b/src/functions/public/Teams/Get-GitHubTeam.ps1
@@ -17,23 +17,25 @@
Get-GitHubTeam -Organization 'github' -Slug 'my-team-name'
Gets the team with the slug 'my-team-name' in the `github` organization.
+
+ .NOTES
+ [List teams](https://docs.github.com/rest/teams/teams#list-teams)
+
+ .LINK
+ https://psmodule.io/GitHub/Functions/Teams/Get-GitHubTeam
#>
[OutputType([GitHubTeam])]
- [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')]
+ [CmdletBinding(DefaultParameterSetName = 'List all teams in an organization')]
param(
- # The slug of the team name.
- [Parameter(
- Mandatory,
- ParameterSetName = 'BySlug'
- )]
- [Alias('team_slug')]
- [string] $Slug,
-
# The organization name. The name is not case sensitive.
# If not provided, the owner from the context will be used.
- [Parameter()]
+ [Parameter(Mandatory)]
[string] $Organization,
+ # The slug of the team name.
+ [Parameter(Mandatory, ParameterSetName = 'BySlug')]
+ [string] $Slug,
+
# The context to run the command in. Used to get the details for the API call.
# Can be either a string or a GitHubContext object.
[Parameter()]
@@ -45,11 +47,6 @@
Write-Debug "[$stackPath] - Start"
$Context = Resolve-GitHubContext -Context $Context
Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
-
- if ([string]::IsNullOrEmpty($Organization)) {
- $Organization = $Context.Owner
- }
- Write-Debug "Organization: [$Organization]"
}
process {
@@ -71,5 +68,3 @@
Write-Debug "[$stackPath] - End"
}
}
-
-#SkipTest:FunctionTest:Will add a test for this function in a future PR
diff --git a/src/functions/public/Teams/New-GitHubTeam.ps1 b/src/functions/public/Teams/New-GitHubTeam.ps1
index 2ec5e4dfc..dbb14f17d 100644
--- a/src/functions/public/Teams/New-GitHubTeam.ps1
+++ b/src/functions/public/Teams/New-GitHubTeam.ps1
@@ -24,21 +24,24 @@
}
New-GitHubTeam @params
+ .LINK
+ https://psmodule.io/GitHub/Functions/Teams/New-GitHubTeam
+
.NOTES
[Create a team](https://docs.github.com/rest/teams/teams#create-a-team)
#>
[OutputType([GitHubTeam])]
[CmdletBinding(SupportsShouldProcess)]
param(
- # The name of the team.
- [Parameter(Mandatory)]
- [string] $Name,
-
# The organization name. The name is not case sensitive.
# If not provided, the organization from the context is used.
[Parameter(Mandatory)]
[string] $Organization,
+ # The name of the team.
+ [Parameter(Mandatory)]
+ [string] $Name,
+
# The description of the team.
[Parameter()]
[string] $Description,
@@ -47,7 +50,8 @@
[Parameter()]
[string[]] $Maintainers,
- # The full name (e.g., "organization-name/repository-name") of repositories to add the team to.
+ # The full name of repositories to add the team to.
+ # Example: 'github/octocat' or 'octocat/Hello-World'
[Parameter()]
[string[]] $RepoNames,
@@ -76,7 +80,7 @@
# The ID of a team to set as the parent team.
[Parameter()]
- [int] $ParentTeamID = 0,
+ [System.Nullable[int]] $ParentTeamID,
# The context to run the command in. Used to get the details for the API call.
# Can be either a string or a GitHubContext object.
@@ -104,7 +108,7 @@
privacy = $Visible ? 'closed' : 'secret'
notification_setting = $Notifications ? 'notifications_enabled' : 'notifications_disabled'
permission = $Permission
- parent_team_id = $ParentTeamID -eq 0 ? $null : $ParentTeamID
+ parent_team_id = $ParentTeamID
}
$body | Remove-HashtableEntry -NullOrEmptyValues
@@ -123,13 +127,14 @@
Name = $team.name
Slug = $team.slug
NodeID = $team.node_id
+ Url = $team.html_url
CombinedSlug = $Organization + '/' + $team.slug
ID = $team.id
Description = $team.description
Notifications = $team.notification_setting -eq 'notifications_enabled' ? $true : $false
Visible = $team.privacy -eq 'closed' ? $true : $false
ParentTeam = $team.parent.slug
- Organization = $team.organization.login
+ Organization = $Organization
ChildTeams = @()
CreatedAt = $team.created_at
UpdatedAt = $team.updated_at
@@ -143,5 +148,3 @@
Write-Debug "[$stackPath] - End"
}
}
-
-#SkipTest:FunctionTest:Will add a test for this function in a future PR
diff --git a/src/functions/public/Teams/Remove-GitHubTeam.ps1 b/src/functions/public/Teams/Remove-GitHubTeam.ps1
index 1f3c523e4..bdeabf2d6 100644
--- a/src/functions/public/Teams/Remove-GitHubTeam.ps1
+++ b/src/functions/public/Teams/Remove-GitHubTeam.ps1
@@ -12,26 +12,22 @@
.NOTES
[Delete a team](https://docs.github.com/rest/teams/teams#delete-a-team)
+
+ .LINK
+ https://psmodule.io/GitHub/Functions/Teams/Remove-GitHubTeam
#>
[OutputType([void])]
[CmdletBinding(SupportsShouldProcess)]
param(
- # The slug of the team name.
- [Parameter(
- Mandatory,
- ValueFromPipelineByPropertyName
- )]
- [Alias('team_slug', 'Slug')]
- [string] $Name,
-
# The organization name. The name is not case sensitive.
# If not provided, the organization from the context is used.
- [Parameter(
- Mandatory,
- ValueFromPipelineByPropertyName
- )]
+ [Parameter(Mandatory, ValueFromPipelineByPropertyName)]
[string] $Organization,
+ # The slug of the team name.
+ [Parameter(Mandatory, ValueFromPipelineByPropertyName)]
+ [string] $Slug,
+
# The context to run the command in. Used to get the details for the API call.
# Can be either a string or a GitHubContext object.
[Parameter()]
@@ -48,11 +44,11 @@
process {
$inputObject = @{
Method = 'DELETE'
- APIEndpoint = "/orgs/$Organization/teams/$Name"
+ APIEndpoint = "/orgs/$Organization/teams/$Slug"
Context = $Context
}
- if ($PSCmdlet.ShouldProcess("$Organization/$Name", 'DELETE')) {
+ if ($PSCmdlet.ShouldProcess("$Organization/$Slug", 'DELETE')) {
Invoke-GitHubAPI @inputObject | ForEach-Object {
Write-Output $_.Response
}
@@ -63,5 +59,3 @@
Write-Debug "[$stackPath] - End"
}
}
-
-#SkipTest:FunctionTest:Will add a test for this function in a future PR
diff --git a/src/functions/public/Teams/Update-GitHubTeam.ps1 b/src/functions/public/Teams/Update-GitHubTeam.ps1
index 8d03d242f..a6c842172 100644
--- a/src/functions/public/Teams/Update-GitHubTeam.ps1
+++ b/src/functions/public/Teams/Update-GitHubTeam.ps1
@@ -24,20 +24,22 @@
.NOTES
[Update a team](https://docs.github.com/rest/teams/teams#update-a-team)
+
+ .LINK
+ https://psmodule.io/GitHub/Functions/Teams/Update-GitHubTeam
#>
[OutputType([GitHubTeam])]
[CmdletBinding(SupportsShouldProcess)]
param(
- # The slug of the team name.
- [Parameter(Mandatory)]
- [Alias('team_slug', 'Slug')]
- [string] $Name,
-
# The organization name. The name is not case sensitive.
# If you do not provide this parameter, the command will use the organization from the context.
[Parameter(Mandatory)]
[string] $Organization,
+ # The slug of the team name.
+ [Parameter(Mandatory)]
+ [string] $Slug,
+
# The new team name.
[Parameter()]
[Alias()]
@@ -102,12 +104,12 @@
$inputObject = @{
Method = 'PATCH'
- APIEndpoint = "/orgs/$Organization/teams/$Name"
+ APIEndpoint = "/orgs/$Organization/teams/$Slug"
Body = $body
Context = $Context
}
- if ($PSCmdlet.ShouldProcess("$Organization/$Name", 'Update')) {
+ if ($PSCmdlet.ShouldProcess("$Organization/$Slug", 'Update')) {
Invoke-GitHubAPI @inputObject | ForEach-Object {
$team = $_.Response
[GitHubTeam](
@@ -115,13 +117,14 @@
Name = $team.name
Slug = $team.slug
NodeID = $team.node_id
+ Url = $team.html_url
CombinedSlug = $Organization + '/' + $team.slug
ID = $team.id
Description = $team.description
Notifications = $team.notification_setting -eq 'notifications_enabled' ? $true : $false
Visible = $team.privacy -eq 'closed' ? $true : $false
ParentTeam = $team.parent.slug
- Organization = $team.organization.login
+ Organization = $Organization
ChildTeams = @()
CreatedAt = $team.created_at
UpdatedAt = $team.updated_at
@@ -135,5 +138,3 @@
Write-Debug "[$stackPath] - End"
}
}
-
-#SkipTest:FunctionTest:Will add a test for this function in a future PR
diff --git a/src/functions/public/Workflows/Disable-GitHubWorkflow.ps1 b/src/functions/public/Workflows/Disable-GitHubWorkflow.ps1
index 982fda969..624b60ac7 100644
--- a/src/functions/public/Workflows/Disable-GitHubWorkflow.ps1
+++ b/src/functions/public/Workflows/Disable-GitHubWorkflow.ps1
@@ -13,9 +13,9 @@
GitHubWorkflow
.LINK
- https://psmodule.io/GitHub/Functions/Actions/Workflows/Disable-GitHubWorkflow/
+ https://psmodule.io/GitHub/Functions/Workflows/Disable-GitHubWorkflow/
- .LINK
+ .NOTES
[Disable a workflow](https://docs.github.com/rest/actions/workflows#disable-a-workflow)
#>
[CmdletBinding(SupportsShouldProcess)]
diff --git a/src/functions/public/Workflows/Enable-GitHubWorkflow.ps1 b/src/functions/public/Workflows/Enable-GitHubWorkflow.ps1
index 75018632f..dfd1b7768 100644
--- a/src/functions/public/Workflows/Enable-GitHubWorkflow.ps1
+++ b/src/functions/public/Workflows/Enable-GitHubWorkflow.ps1
@@ -10,9 +10,9 @@
GitHubWorkflow
.LINK
- https://psmodule.io/GitHub/Functions/Actions/Workflows/Enable-GitHubWorkflow/
+ https://psmodule.io/GitHub/Functions/Workflows/Enable-GitHubWorkflow/
- .LINK
+ .NOTES
[Enable a workflow](https://docs.github.com/rest/actions/workflows#enable-a-workflow)
#>
[CmdletBinding(SupportsShouldProcess)]
diff --git a/src/functions/public/Workflows/Get-GitHubWorkflow.ps1 b/src/functions/public/Workflows/Get-GitHubWorkflow.ps1
index 017aa5769..dd4fbbff5 100644
--- a/src/functions/public/Workflows/Get-GitHubWorkflow.ps1
+++ b/src/functions/public/Workflows/Get-GitHubWorkflow.ps1
@@ -22,9 +22,9 @@
GitHubWorkflow
.LINK
- https://psmodule.io/GitHub/Functions/Actions/Workflows/Get-GitHubWorkflow/
+ https://psmodule.io/GitHub/Functions/Workflows/Get-GitHubWorkflow/
- .LINK
+ .NOTES
[List repository workflows](https://docs.github.com/rest/actions/workflows#list-repository-workflows)
#>
[OutputType([GitHubWorkflow])]
diff --git a/src/functions/public/Workflows/Runs/Get-GitHubWorkflowRun.ps1 b/src/functions/public/Workflows/Runs/Get-GitHubWorkflowRun.ps1
index 67a212816..1892d1075 100644
--- a/src/functions/public/Workflows/Runs/Get-GitHubWorkflowRun.ps1
+++ b/src/functions/public/Workflows/Runs/Get-GitHubWorkflowRun.ps1
@@ -39,12 +39,10 @@
GitHubWorkflowRun
.LINK
- https://psmodule.io/GitHub/Functions/Actions/Workflows/Runs/Get-GitHubWorkflowRun/
+ https://psmodule.io/GitHub/Functions/Workflows/Runs/Get-GitHubWorkflowRun/
- .LINK
+ .NOTES
[List workflow runs for a workflow](https://docs.github.com/rest/actions/workflow-runs#list-workflow-runs-for-a-workflow)
-
- .LINK
[List workflow runs for a repository](https://docs.github.com/rest/actions/workflow-runs#list-workflow-runs-for-a-repository)
#>
[OutputType([GitHubWorkflowRun])]
diff --git a/src/functions/public/Workflows/Runs/Remove-GitHubWorkflowRun.ps1 b/src/functions/public/Workflows/Runs/Remove-GitHubWorkflowRun.ps1
index 33ada5bcc..949ca5a50 100644
--- a/src/functions/public/Workflows/Runs/Remove-GitHubWorkflowRun.ps1
+++ b/src/functions/public/Workflows/Runs/Remove-GitHubWorkflowRun.ps1
@@ -17,9 +17,9 @@
GitHubWorkflowRun
.LINK
- https://psmodule.io/GitHub/Functions/Actions/Workflows/Runs/Remove-GitHubWorkflowRun/
+ https://psmodule.io/GitHub/Functions/Workflows/Runs/Remove-GitHubWorkflowRun/
- .LINK
+ .NOTES
[Delete a workflow run](https://docs.github.com/rest/actions/workflow-runs#delete-a-workflow-run)
#>
[CmdletBinding(SupportsShouldProcess)]
diff --git a/src/functions/public/Workflows/Runs/Restart-GitHubWorkflowRun.ps1 b/src/functions/public/Workflows/Runs/Restart-GitHubWorkflowRun.ps1
index 0b5fb0fff..b36c81400 100644
--- a/src/functions/public/Workflows/Runs/Restart-GitHubWorkflowRun.ps1
+++ b/src/functions/public/Workflows/Runs/Restart-GitHubWorkflowRun.ps1
@@ -13,9 +13,9 @@
GitHubWorkflowRun
.LINK
- https://psmodule.io/GitHub/Functions/Actions/Workflows/Runs/Restart-GitHubWorkflowRun/
+ https://psmodule.io/GitHub/Functions/Workflows/Runs/Restart-GitHubWorkflowRun/
- .LINK
+ .NOTES
[Re-run a workflow](https://docs.github.com/rest/actions/workflow-runs#re-run-a-workflow)
#>
[CmdletBinding(SupportsShouldProcess)]
diff --git a/src/functions/public/Workflows/Runs/Stop-GitHubWorkflowRun.ps1 b/src/functions/public/Workflows/Runs/Stop-GitHubWorkflowRun.ps1
index 0045ed5f5..a1422096f 100644
--- a/src/functions/public/Workflows/Runs/Stop-GitHubWorkflowRun.ps1
+++ b/src/functions/public/Workflows/Runs/Stop-GitHubWorkflowRun.ps1
@@ -15,9 +15,9 @@
GitHubWorkflowRun
.LINK
- https://psmodule.io/GitHub/Functions/Actions/Workflows/Runs/Stop-GitHubWorkflowRun/
+ https://psmodule.io/GitHub/Functions/Workflows/Runs/Stop-GitHubWorkflowRun/
- .LINK
+ .NOTES
[Cancel a workflow run](https://docs.github.com/rest/actions/workflow-runs#cancel-a-workflow-run)
#>
[CmdletBinding(SupportsShouldProcess)]
diff --git a/src/functions/public/Workflows/Start-GitHubWorkflow.ps1 b/src/functions/public/Workflows/Start-GitHubWorkflow.ps1
index 3abd9c5ec..f89866165 100644
--- a/src/functions/public/Workflows/Start-GitHubWorkflow.ps1
+++ b/src/functions/public/Workflows/Start-GitHubWorkflow.ps1
@@ -15,9 +15,9 @@
}
.LINK
- https://psmodule.io/GitHub/Functions/Actions/Workflows/Start-GitHubWorkflow/
+ https://psmodule.io/GitHub/Functions/Workflows/Start-GitHubWorkflow/
- .LINK
+ .NOTES
[Create a workflow dispatch event](https://docs.github.com/rest/actions/workflows#create-a-workflow-dispatch-event)
#>
[CmdletBinding(SupportsShouldProcess)]
@@ -79,9 +79,7 @@
}
if ($PSCmdlet.ShouldProcess("$Owner/$Repository/$ID", 'Start workflow')) {
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
- }
+ $null = Invoke-GitHubAPI @inputObject
}
}
diff --git a/src/types/GitHubTeam.Types.ps1xml b/src/types/GitHubTeam.Types.ps1xml
new file mode 100644
index 000000000..38abc2cc2
--- /dev/null
+++ b/src/types/GitHubTeam.Types.ps1xml
@@ -0,0 +1,12 @@
+
+
+
+ GitHubTeam
+
+
+ Team
+ $this.Slug
+
+
+
+
diff --git a/tests/Environments.Tests.ps1 b/tests/Environments.Tests.ps1
index 4007f92b6..024be230b 100644
--- a/tests/Environments.Tests.ps1
+++ b/tests/Environments.Tests.ps1
@@ -21,7 +21,6 @@ param()
BeforeAll {
$testName = 'EnvironmentsTests'
- $environmentName = 'production'
$os = $env:RUNNER_OS
$guid = [guid]::NewGuid().ToString()
}
@@ -41,14 +40,16 @@ Describe 'Environments' {
Write-Host ($context | Format-List | Out-String)
}
}
- $repoPrefix = "$testName-$os-$TokenType"
- $repoName = "$repoPrefix-$guid"
+ $repoPrefix = "$testName-$os-$TokenType-$guid"
+ $repoName = $repoPrefix
+ $environmentName = "$testName-$os-$TokenType-$guid"
+
switch ($OwnerType) {
'user' {
- New-GitHubRepository -Name $repoName -AllowSquashMerge -Debug -Confirm:$false
+ New-GitHubRepository -Name $repoName -AllowSquashMerge -Confirm:$false
}
'organization' {
- New-GitHubRepository -Organization $owner -Name $repoName -AllowSquashMerge -Debug -Confirm:$false
+ New-GitHubRepository -Organization $owner -Name $repoName -AllowSquashMerge -Confirm:$false
}
}
}
diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1
index 267dfa765..2c6daf84e 100644
--- a/tests/GitHub.Tests.ps1
+++ b/tests/GitHub.Tests.ps1
@@ -124,7 +124,7 @@ Describe 'GitHub' {
Context 'Config' {
It 'Get-GitHubConfig - Gets the module configuration' {
$config = Get-GitHubConfig
- Write-Verbose ($config | Format-Table | Out-String) -Verbose
+ Write-Host ($config | Format-Table | Out-String)
$config | Should -Not -BeNullOrEmpty
}
It 'Get-GitHubConfig - Gets a configuration item by name' {
@@ -152,12 +152,12 @@ Describe 'GitHub' {
Context 'Actions' {
It 'Get-GitHubEventData - Gets data about the event that triggered the workflow' {
$workflow = Get-GitHubEventData
- Write-Verbose ($workflow | Format-List | Out-String) -Verbose
+ Write-Host ($workflow | Format-List | Out-String)
$workflow | Should -Not -BeNullOrEmpty
}
It 'Get-GitHubRunnerData - Gets data about the runner that is running the workflow' {
$workflow = Get-GitHubRunnerData
- Write-Verbose ($workflow | Format-List | Out-String) -Verbose
+ Write-Host ($workflow | Format-List | Out-String)
$workflow | Should -Not -BeNullOrEmpty
}
}
@@ -287,7 +287,7 @@ string
{
Get-GitHubOutput
} | Should -Not -Throw
- Write-Verbose (Get-GitHubOutput | Format-List | Out-String) -Verbose
+ Write-Host (Get-GitHubOutput | Format-List | Out-String)
}
It 'Set-GitHubEnvironmentVariable - Should not throw' {
{
@@ -310,15 +310,15 @@ string
Context 'IssueParser' {
BeforeAll {
$issueTestFilePath = Join-Path -Path $PSScriptRoot -ChildPath 'Data/IssueForm.md'
- Write-Verbose "Reading from $issueTestFilePath" -Verbose
+ Write-Host "Reading from $issueTestFilePath"
$content = Get-Content -Path $issueTestFilePath -Raw
- Write-Verbose ($content | Out-String) -Verbose
- $dataObject = $content | ConvertFrom-IssueForm -Verbose
- Write-Verbose 'As PSCustomObject' -Verbose
- Write-Verbose ($dataObject | Format-List | Out-String) -Verbose
- $dataHashtable = $content | ConvertFrom-IssueForm -AsHashtable -Verbose
- Write-Verbose 'As Hashtable' -Verbose
- Write-Verbose ($dataHashtable | Out-String) -Verbose
+ Write-Host ($content | Out-String)
+ $dataObject = $content | ConvertFrom-IssueForm
+ Write-Host 'As PSCustomObject'
+ Write-Host ($dataObject | Format-List | Out-String)
+ $dataHashtable = $content | ConvertFrom-IssueForm -AsHashtable
+ Write-Host 'As Hashtable'
+ Write-Host ($dataHashtable | Out-String)
}
It 'ConvertFrom-IssueForm - Should return a PSCustomObject' {
@@ -330,13 +330,13 @@ string
}
It "'Type with spaces' should contain 'Action'" {
- Write-Verbose ($dataHashtable['Type with spaces'] | Out-String) -Verbose
+ Write-Host ($dataHashtable['Type with spaces'] | Out-String)
$dataHashtable.Keys | Should -Contain 'Type with spaces'
$dataHashtable['Type with spaces'] | Should -Be 'Action'
}
It "'Multiline' should contain a multiline string with 3 lines" {
- Write-Verbose ($dataHashtable['Multiline'] | Out-String) -Verbose
+ Write-Host ($dataHashtable['Multiline'] | Out-String)
$dataHashtable.Keys | Should -Contain 'Multiline'
$dataHashtable['Multiline'] | Should -Be @'
test
@@ -346,7 +346,7 @@ line
}
It "'OS' should contain a hashtable with 3 items" {
- Write-Verbose ($dataHashtable['OS'] | Out-String) -Verbose
+ Write-Host ($dataHashtable['OS'] | Out-String)
$dataHashtable.Keys | Should -Contain 'OS'
$dataHashtable['OS'].Windows | Should -BeTrue
$dataHashtable['OS'].Linux | Should -BeTrue
diff --git a/tests/Secrets.Tests.ps1 b/tests/Secrets.Tests.ps1
index e9c003f58..6d909b181 100644
--- a/tests/Secrets.Tests.ps1
+++ b/tests/Secrets.Tests.ps1
@@ -36,37 +36,36 @@ Describe 'Secrets' {
Write-Host ($context | Format-List | Out-String)
}
}
- $repoPrefix = "$testName-$os-$TokenType"
- $repoName = "$repoPrefix-$guid"
+ $repoPrefix = "$testName-$os-$TokenType-$guid"
$secretPrefix = ("$testName`_$os`_$TokenType`_$guid" -replace '-', '_').ToUpper()
+ $orgSecretName = "$secretPrefix`ORG"
$environmentName = "$testName-$os-$TokenType-$guid"
switch ($OwnerType) {
'user' {
- $repo = New-GitHubRepository -Name $repoName -AllowSquashMerge
- $repo2 = New-GitHubRepository -Name "$repoName-2" -AllowSquashMerge
- $repo3 = New-GitHubRepository -Name "$repoName-3" -AllowSquashMerge
+ $repo = New-GitHubRepository -Name "$repoPrefix-1" -AllowSquashMerge
+ $repo2 = New-GitHubRepository -Name "$repoPrefix-2" -AllowSquashMerge
+ $repo3 = New-GitHubRepository -Name "$repoPrefix-3" -AllowSquashMerge
}
'organization' {
- $repo = New-GitHubRepository -Organization $owner -Name $repoName -AllowSquashMerge
- $repo2 = New-GitHubRepository -Organization $owner -Name "$repoName-2" -AllowSquashMerge
- $repo3 = New-GitHubRepository -Organization $owner -Name "$repoName-3" -AllowSquashMerge
+ $repo = New-GitHubRepository -Organization $owner -Name "$repoPrefix-1" -AllowSquashMerge
+ $repo2 = New-GitHubRepository -Organization $owner -Name "$repoPrefix-2" -AllowSquashMerge
+ $repo3 = New-GitHubRepository -Organization $owner -Name "$repoPrefix-3" -AllowSquashMerge
LogGroup "Org secret - [$secretPrefix]" {
$params = @{
Owner = $owner
+ Name = $orgSecretName
Value = 'organization'
Visibility = 'selected'
SelectedRepositories = $repo.id
}
- $result = @()
- $result += Set-GitHubSecret @params -Name "$secretPrefix"
- $result += Set-GitHubSecret @params -Name "$secretPrefix`_2"
- $result += Set-GitHubSecret @params -Name "$secretPrefix`_3"
- Write-Host ($result | Select-Object * | Format-Table | Out-String)
+
+ $orgSecret += Set-GitHubSecret @params
+ Write-Host ($orgSecret | Select-Object * | Format-Table | Out-String)
}
}
}
- LogGroup "Repository - [$repoName]" {
+ LogGroup "Repository - [$repoPrefix]" {
Write-Host ($repo | Format-List | Out-String)
Write-Host ($repo2 | Format-List | Out-String)
Write-Host ($repo3 | Format-List | Out-String)
@@ -79,11 +78,11 @@ Describe 'Secrets' {
Get-GitHubRepository | Where-Object { $_.Name -like "$repoPrefix*" } | Remove-GitHubRepository -Confirm:$false
}
'organization' {
- $orgSecrets = Get-GitHubSecret -Owner $owner | Where-Object { $_.Name -like "$secretPrefix*" }
LogGroup 'Secrets to remove' {
+ $orgSecrets = Get-GitHubSecret -Owner $owner | Where-Object { $_.Name -like "$secretPrefix*" }
Write-Host "$($orgSecrets | Format-List | Out-String)"
+ $orgSecrets | Remove-GitHubSecret
}
- $orgSecrets | Remove-GitHubSecret
LogGroup 'Repos to remove' {
$reposToRemove = Get-GitHubRepository -Organization $Owner | Where-Object { $_.Name -like "$repoPrefix*" }
Write-Host "$($reposToRemove | Format-List | Out-String)"
@@ -228,8 +227,8 @@ Describe 'Secrets' {
Context 'SelectedRepository' {
It 'Get-GitHubSecretSelectedRepository - gets a list of selected repositories' {
- LogGroup "SelectedRepositories - [$secretPrefix]" {
- $result = Get-GitHubSecretSelectedRepository -Owner $owner -Name $secretPrefix
+ LogGroup "SelectedRepositories - [$orgSecretName]" {
+ $result = Get-GitHubSecretSelectedRepository -Owner $owner -Name $orgSecretName
Write-Host "$($result | Select-Object * | Format-Table | Out-String)"
}
$result | Should -Not -BeNullOrEmpty
@@ -237,20 +236,20 @@ Describe 'Secrets' {
$result | Should -HaveCount 1
}
It 'Add-GitHubSecretSelectedRepository - adds a repository to the list of selected repositories' {
- { Add-GitHubSecretSelectedRepository -Owner $owner -Name $secretPrefix -RepositoryID $repo2.id } | Should -Not -Throw
+ { Add-GitHubSecretSelectedRepository -Owner $owner -Name $orgSecretName -RepositoryID $repo2.id } | Should -Not -Throw
}
It 'Add-GitHubSecretSelectedRepository - adds a repository to the list of selected repositories - idempotency test' {
- { Add-GitHubSecretSelectedRepository -Owner $owner -Name $secretPrefix -RepositoryID $repo2.id } | Should -Not -Throw
+ { Add-GitHubSecretSelectedRepository -Owner $owner -Name $orgSecretName -RepositoryID $repo2.id } | Should -Not -Throw
}
It 'Add-GitHubSecretSelectedRepository - adds a repository to the list of selected repositories using pipeline' {
LogGroup 'Repo3' {
Write-Host "$($repo3 | Format-List | Out-String)"
}
- { $repo3 | Add-GitHubSecretSelectedRepository -Owner $owner -Name $secretPrefix } | Should -Not -Throw
+ { $repo3 | Add-GitHubSecretSelectedRepository -Owner $owner -Name $orgSecretName } | Should -Not -Throw
}
It 'Get-GitHubSecretSelectedRepository - gets 3 repositories' {
- LogGroup "SelectedRepositories - [$secretPrefix]" {
- $result = Get-GitHubSecretSelectedRepository -Owner $owner -Name $secretPrefix
+ LogGroup "SelectedRepositories - [$orgSecretName]" {
+ $result = Get-GitHubSecretSelectedRepository -Owner $owner -Name $orgSecretName
Write-Host "$($result | Select-Object * | Format-Table | Out-String)"
}
$result | Should -Not -BeNullOrEmpty
@@ -258,20 +257,20 @@ Describe 'Secrets' {
$result | Should -HaveCount 3
}
It 'Remove-GitHubSecretSelectedRepository - removes a repository from the list of selected repositories' {
- { Remove-GitHubSecretSelectedRepository -Owner $owner -Name $secretPrefix -RepositoryID $repo2.id } | Should -Not -Throw
+ { Remove-GitHubSecretSelectedRepository -Owner $owner -Name $orgSecretName -RepositoryID $repo2.id } | Should -Not -Throw
}
It 'Remove-GitHubSecretSelectedRepository - removes a repository from the list of selected repositories - idempotency test' {
- { Remove-GitHubSecretSelectedRepository -Owner $owner -Name $secretPrefix -RepositoryID $repo2.id } | Should -Not -Throw
+ { Remove-GitHubSecretSelectedRepository -Owner $owner -Name $orgSecretName -RepositoryID $repo2.id } | Should -Not -Throw
}
It 'Remove-GitHubSecretSelectedRepository - removes a repository from the list of selected repositories using pipeline' {
LogGroup 'Repo3' {
Write-Host "$($repo3 | Format-List | Out-String)"
}
- { $repo3 | Remove-GitHubSecretSelectedRepository -Owner $owner -Name $secretPrefix } | Should -Not -Throw
+ { $repo3 | Remove-GitHubSecretSelectedRepository -Owner $owner -Name $orgSecretName } | Should -Not -Throw
}
It 'Get-GitHubSecretSelectedRepository - gets 1 repository' {
- LogGroup "SelectedRepositories - [$secretPrefix]" {
- $result = Get-GitHubSecretSelectedRepository -Owner $owner -Name $secretPrefix
+ LogGroup "SelectedRepositories - [$orgSecretName]" {
+ $result = Get-GitHubSecretSelectedRepository -Owner $owner -Name $orgSecretName
Write-Host "$($result | Select-Object * | Format-Table | Out-String)"
}
$result | Should -Not -BeNullOrEmpty
@@ -279,16 +278,16 @@ Describe 'Secrets' {
$result | Should -HaveCount 1
}
It 'Set-GitHubSecretSelectedRepository - should set the selected repositories for the secret' {
- { Set-GitHubSecretSelectedRepository -Owner $owner -Name $secretPrefix -RepositoryID $repo.id, $repo2.id, $repo3.id } |
+ { Set-GitHubSecretSelectedRepository -Owner $owner -Name $orgSecretName -RepositoryID $repo.id, $repo2.id, $repo3.id } |
Should -Not -Throw
}
It 'Set-GitHubSecretSelectedRepository - should set the selected repositories for the secret - idempotency test' {
- { Set-GitHubSecretSelectedRepository -Owner $owner -Name $secretPrefix -RepositoryID $repo.id, $repo2.id, $repo3.id } |
+ { Set-GitHubSecretSelectedRepository -Owner $owner -Name $orgSecretName -RepositoryID $repo.id, $repo2.id, $repo3.id } |
Should -Not -Throw
}
It 'Get-GitHubSecretSelectedRepository - gets 3 repository' {
- $result = Get-GitHubSecretSelectedRepository -Owner $owner -Name $secretPrefix
- LogGroup "SelectedRepositories - [$secretPrefix]" {
+ $result = Get-GitHubSecretSelectedRepository -Owner $owner -Name $orgSecretName
+ LogGroup "SelectedRepositories - [$orgSecretName]" {
Write-Host "$($result | Select-Object * | Format-Table | Out-String)"
}
$result | Should -Not -BeNullOrEmpty
@@ -302,9 +301,9 @@ Describe 'Secrets' {
BeforeAll {
$scope = @{
Owner = $owner
- Repository = $repoName
+ Repository = $repo
}
- Set-GitHubSecret @scope -Name $secretPrefix -Value 'repository'
+ Set-GitHubSecret @scope -Name $orgSecretName -Value 'repository'
}
Context 'PublicKey' {
@@ -415,16 +414,16 @@ Describe 'Secrets' {
BeforeAll {
$scope = @{
Owner = $owner
- Repository = $repoName
+ Repository = $repo
}
- Set-GitHubSecret @scope -Name $secretPrefix -Value 'repository'
+ Set-GitHubSecret @scope -Name $orgSecretName -Value 'repository'
$scope = @{
Owner = $owner
- Repository = $repoName
+ Repository = $repo
Environment = $environmentName
}
- Set-GitHubEnvironment -Owner $owner -Repository $repoName -Name $environmentName
- Set-GitHubSecret @scope -Name $secretPrefix -Value 'environment'
+ Set-GitHubEnvironment -Owner $owner -Repository $repo -Name $environmentName
+ Set-GitHubSecret @scope -Name $orgSecretName -Value 'environment'
}
Context 'PublicKey' {
diff --git a/tests/Teams.Tests.ps1 b/tests/Teams.Tests.ps1
new file mode 100644
index 000000000..8587be108
--- /dev/null
+++ b/tests/Teams.Tests.ps1
@@ -0,0 +1,136 @@
+#Requires -Modules @{ ModuleName = 'Pester'; RequiredVersion = '5.7.1' }
+
+[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
+ 'PSUseDeclaredVarsMoreThanAssignments', '',
+ Justification = 'Pester grouping syntax: known issue.'
+)]
+[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
+ 'PSAvoidUsingConvertToSecureStringWithPlainText', '',
+ Justification = 'Used to create a secure string for testing.'
+)]
+[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
+ 'PSAvoidUsingWriteHost', '',
+ Justification = 'Log outputs to GitHub Actions logs.'
+)]
+[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
+ 'PSAvoidLongLines', '',
+ Justification = 'Long test descriptions and skip switches'
+)]
+[CmdletBinding()]
+param()
+
+BeforeAll {
+ $testName = 'TeamsTests'
+ $os = $env:RUNNER_OS
+ $guid = [guid]::NewGuid().ToString()
+}
+
+Describe 'Teams' {
+ $authCases = . "$PSScriptRoot/Data/AuthCases.ps1"
+
+ Context 'As using on ' -ForEach $authCases {
+ BeforeAll {
+ $context = Connect-GitHubAccount @connectParams -PassThru -Silent
+ LogGroup 'Context' {
+ Write-Host ($context | Format-List | Out-String)
+ }
+ if ($AuthType -eq 'APP') {
+ LogGroup 'Context - Installation' {
+ $context = Connect-GitHubApp @connectAppParams -PassThru -Default -Silent
+ Write-Host ($context | Format-List | Out-String)
+ }
+ }
+ $teamPrefix = ("$testName`_$os`_$TokenType`_$guid" -replace '-', '_').ToUpper()
+ }
+
+ AfterAll {
+ switch ($OwnerType) {
+ 'organization' {
+ $teamsToRemove = Get-GitHubTeam -Organization $owner | Where-Object { $_.Name -like "$teamPrefix*" }
+ LogGroup 'Teams to remove' {
+ Write-Host "$($teamsToRemove | Format-List | Out-String)"
+ }
+ $teamsToRemove | Remove-GitHubTeam -Confirm:$false
+ }
+ }
+ Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount -Silent
+ }
+
+ Context 'Organization' -Skip:($OwnerType -ne 'organization') {
+ BeforeAll {
+ $scope = @{
+ Organization = $owner
+ }
+ }
+
+ It 'New-GitHubTeam - Creates a new team' {
+ $teamName = "$teamPrefix`_NewTeam"
+ $teamDescription = 'This is a test team.'
+ $team = New-GitHubTeam @scope -Name $teamName -Description $teamDescription
+ LogGroup 'New Team' {
+ Write-Host ($team | Format-List | Out-String)
+ }
+ $team | Should -Not -BeNullOrEmpty
+ $team.Name | Should -Be $teamName
+ $team.Description | Should -Be $teamDescription
+ }
+
+ It 'Get-GitHubTeam - Gets a team' {
+ $teamName = "$teamPrefix`_NewTeam"
+ $team = Get-GitHubTeam -Organization $owner -Slug $teamName
+ LogGroup 'Get Team' {
+ Write-Host ($team | Format-List | Out-String)
+ }
+ $team | Should -Not -BeNullOrEmpty
+ $team.Name | Should -Be $teamName
+ }
+
+ It 'New-GitHubTeam - Creates 5 new teams' {
+ 1..5 | ForEach-Object {
+ $teamName = "$teamPrefix`_NewTeam_$_"
+ $teamDescription = 'This is a test team.'
+ $team = New-GitHubTeam @scope -Name $teamName -Description $teamDescription
+ LogGroup 'New Team' {
+ Write-Host ($team | Format-List | Out-String)
+ }
+ $team | Should -Not -BeNullOrEmpty
+ $team.Name | Should -Be $teamName
+ $team.Description | Should -Be $teamDescription
+ }
+ }
+
+ It 'Get-GitHubTeam - Gets all teams' {
+ $teams = Get-GitHubTeam -Organization $owner
+ LogGroup 'Get All Teams' {
+ Write-Host ($teams | Format-List | Out-String)
+ }
+ $teams | Should -Not -BeNullOrEmpty
+ $teams.Count | Should -BeGreaterThan 0
+ }
+
+ It 'Update-GitHubTeam - Updates a team' {
+ $teamName = "$teamPrefix`_NewTeam"
+ $newTeamName = "$teamPrefix`_UpdatedTeam"
+ $teamDescription = 'This is an updated test team.'
+ $team = Update-GitHubTeam @scope -Slug $teamName -NewName $newTeamName -Description $teamDescription
+ LogGroup 'Update Team' {
+ Write-Host ($team | Format-List | Out-String)
+ }
+ $team | Should -Not -BeNullOrEmpty
+ $team.Name | Should -Be $newTeamName
+ $team.Description | Should -Be $teamDescription
+ }
+
+ It 'Remove-GitHubTeam - Removes a team' {
+ $teamName = "$teamPrefix`_UpdatedTeam"
+ $team = Get-GitHubTeam -Organization $owner -Slug $teamName
+ LogGroup 'Remove Team' {
+ Write-Host ($team | Format-List | Out-String)
+ }
+ $team | Should -Not -BeNullOrEmpty
+ $team.Name | Should -Be $teamName
+ Remove-GitHubTeam @scope -Slug $teamName -Confirm:$false
+ }
+ }
+ }
+}
diff --git a/tests/Users.Tests.ps1 b/tests/Users.Tests.ps1
index b0e4080e9..c5107d110 100644
--- a/tests/Users.Tests.ps1
+++ b/tests/Users.Tests.ps1
@@ -57,7 +57,6 @@ Describe 'Users' {
{ Update-GitHubUser -Company 'PSModule' } | Should -Not -Throw
{ Update-GitHubUser -Location 'USA' } | Should -Not -Throw
{ Update-GitHubUser -Bio 'I love programming' } | Should -Not -Throw
- { Update-GitHubUser -Hireable $true } | Should -Not -Throw
$tmpUser = Get-GitHubUser
$tmpUser.DisplayName | Should -Be 'Octocat'
$tmpUser.Blog | Should -Be 'https://psmodule.io'
@@ -65,7 +64,10 @@ Describe 'Users' {
$tmpUser.Company | Should -Be 'PSModule'
$tmpUser.Location | Should -Be 'USA'
$tmpUser.Bio | Should -Be 'I love programming'
- $tmpUser.Hireable | Should -Be $true
+
+ # Flaky tests
+ # { Update-GitHubUser -Hireable $true } | Should -Not -Throw
+ # $tmpUser.Hireable | Should -Be $true
}
Context 'Email' {
It 'Get-GitHubUserEmail - Gets all email addresses for the authenticated user' {
diff --git a/tests/Variables.Tests.ps1 b/tests/Variables.Tests.ps1
index 1fcb1ad10..edaef1add 100644
--- a/tests/Variables.Tests.ps1
+++ b/tests/Variables.Tests.ps1
@@ -36,35 +36,35 @@ Describe 'Variables' {
Write-Host ($context | Format-List | Out-String)
}
}
- $repoPrefix = "$testName-$os-$TokenType"
- $repoName = "$repoPrefix-$guid"
+ $repoPrefix = "$testName-$os-$TokenType-$guid"
$variablePrefix = ("$testName`_$os`_$TokenType`_$guid" -replace '-', '_').ToUpper()
+ $orgVariableName = "$variablePrefix`ORG"
$environmentName = "$testName-$os-$TokenType-$guid"
switch ($OwnerType) {
'user' {
- $repo = New-GitHubRepository -Name $repoName -AllowSquashMerge
- $repo2 = New-GitHubRepository -Name "$repoName-2" -AllowSquashMerge
- $repo3 = New-GitHubRepository -Name "$repoName-3" -AllowSquashMerge
+ $repo = New-GitHubRepository -Name "$repoPrefix-1" -AllowSquashMerge
+ $repo2 = New-GitHubRepository -Name "$repoPrefix-2" -AllowSquashMerge
+ $repo3 = New-GitHubRepository -Name "$repoPrefix-3" -AllowSquashMerge
}
'organization' {
- $repo = New-GitHubRepository -Organization $owner -Name $repoName -AllowSquashMerge
- $repo2 = New-GitHubRepository -Organization $owner -Name "$repoName-2" -AllowSquashMerge
- $repo3 = New-GitHubRepository -Organization $owner -Name "$repoName-3" -AllowSquashMerge
+ $repo = New-GitHubRepository -Organization $owner -Name "$repoPrefix-1" -AllowSquashMerge
+ $repo2 = New-GitHubRepository -Organization $owner -Name "$repoPrefix-2" -AllowSquashMerge
+ $repo3 = New-GitHubRepository -Organization $owner -Name "$repoPrefix-3" -AllowSquashMerge
LogGroup "Org variable - [$variablePrefix]" {
$params = @{
Owner = $owner
- Name = $variablePrefix
+ Name = $orgVariableName
Value = 'organization'
Visibility = 'selected'
SelectedRepositories = $repo.id
}
- $result = Set-GitHubVariable @params
- Write-Host ($result | Select-Object * | Format-Table | Out-String)
+ $orgVariable = Set-GitHubVariable @params
+ Write-Host ($orgVariable | Select-Object * | Format-Table | Out-String)
}
}
}
- LogGroup "Repository - [$repoName]" {
+ LogGroup "Repository - [$repoPrefix]" {
Write-Host ($repo | Format-Table | Out-String)
Write-Host ($repo2 | Format-Table | Out-String)
Write-Host ($repo3 | Format-Table | Out-String)
@@ -242,8 +242,8 @@ Describe 'Variables' {
Context 'SelectedRepository' -Tag 'Flaky' {
It 'Get-GitHubVariableSelectedRepository - gets a list of selected repositories' {
- LogGroup "SelectedRepositories - [$variablePrefix]" {
- $result = Get-GitHubVariableSelectedRepository -Owner $owner -Name $variablePrefix
+ LogGroup "SelectedRepositories - [$orgVariableName]" {
+ $result = Get-GitHubVariableSelectedRepository -Owner $owner -Name $orgVariableName
Write-Host "$($result | Select-Object * | Format-Table | Out-String)"
}
$result | Should -Not -BeNullOrEmpty
@@ -251,20 +251,20 @@ Describe 'Variables' {
$result | Should -HaveCount 1
}
It 'Add-GitHubVariableSelectedRepository - adds a repository to the list of selected repositories' {
- { Add-GitHubVariableSelectedRepository -Owner $owner -Name $variablePrefix -RepositoryID $repo2.id } | Should -Not -Throw
+ { Add-GitHubVariableSelectedRepository -Owner $owner -Name $orgVariableName -RepositoryID $repo2.id } | Should -Not -Throw
}
It 'Add-GitHubVariableSelectedRepository - adds a repository to the list of selected repositories - idempotency test' {
- { Add-GitHubVariableSelectedRepository -Owner $owner -Name $variablePrefix -RepositoryID $repo2.id } | Should -Not -Throw
+ { Add-GitHubVariableSelectedRepository -Owner $owner -Name $orgVariableName -RepositoryID $repo2.id } | Should -Not -Throw
}
It 'Add-GitHubVariableSelectedRepository - adds a repository to the list of selected repositories using pipeline' {
LogGroup 'Repo3' {
Write-Host "$($repo3 | Format-List | Out-String)"
}
- { $repo3 | Add-GitHubVariableSelectedRepository -Owner $owner -Name $variablePrefix } | Should -Not -Throw
+ { $repo3 | Add-GitHubVariableSelectedRepository -Owner $owner -Name $orgVariableName } | Should -Not -Throw
}
It 'Get-GitHubVariableSelectedRepository - gets 3 repositories' {
- LogGroup "SelectedRepositories - [$variablePrefix]" {
- $result = Get-GitHubVariableSelectedRepository -Owner $owner -Name $variablePrefix
+ LogGroup "SelectedRepositories - [$orgVariableName]" {
+ $result = Get-GitHubVariableSelectedRepository -Owner $owner -Name $orgVariableName
Write-Host "$($result | Select-Object * | Format-Table | Out-String)"
}
$result | Should -Not -BeNullOrEmpty
@@ -272,20 +272,20 @@ Describe 'Variables' {
$result | Should -HaveCount 3
}
It 'Remove-GitHubVariableSelectedRepository - removes a repository from the list of selected repositories' {
- { Remove-GitHubVariableSelectedRepository -Owner $owner -Name $variablePrefix -RepositoryID $repo2.id } | Should -Not -Throw
+ { Remove-GitHubVariableSelectedRepository -Owner $owner -Name $orgVariableName -RepositoryID $repo2.id } | Should -Not -Throw
}
It 'Remove-GitHubVariableSelectedRepository - removes a repository from the list of selected repositories - idempotency test' {
- { Remove-GitHubVariableSelectedRepository -Owner $owner -Name $variablePrefix -RepositoryID $repo2.id } | Should -Not -Throw
+ { Remove-GitHubVariableSelectedRepository -Owner $owner -Name $orgVariableName -RepositoryID $repo2.id } | Should -Not -Throw
}
It 'Remove-GitHubVariableSelectedRepository - removes a repository from the list of selected repositories using pipeline' {
LogGroup 'Repo3' {
Write-Host "$($repo3 | Format-List | Out-String)"
}
- { $repo3 | Remove-GitHubVariableSelectedRepository -Owner $owner -Name $variablePrefix } | Should -Not -Throw
+ { $repo3 | Remove-GitHubVariableSelectedRepository -Owner $owner -Name $orgVariableName } | Should -Not -Throw
}
It 'Get-GitHubVariableSelectedRepository - gets 1 repository' {
- LogGroup "SelectedRepositories - [$variablePrefix]" {
- $result = Get-GitHubVariableSelectedRepository -Owner $owner -Name $variablePrefix
+ LogGroup "SelectedRepositories - [$orgVariableName]" {
+ $result = Get-GitHubVariableSelectedRepository -Owner $owner -Name $orgVariableName
Write-Host "$($result | Select-Object * | Format-Table | Out-String)"
}
$result | Should -Not -BeNullOrEmpty
@@ -293,16 +293,16 @@ Describe 'Variables' {
$result | Should -HaveCount 1
}
It 'Set-GitHubVariableSelectedRepository - should set the selected repositories for the variable' {
- { Set-GitHubVariableSelectedRepository -Owner $owner -Name $variablePrefix -RepositoryID $repo.id, $repo2.id, $repo3.id } |
+ { Set-GitHubVariableSelectedRepository -Owner $owner -Name $orgVariableName -RepositoryID $repo.id, $repo2.id, $repo3.id } |
Should -Not -Throw
}
It 'Set-GitHubVariableSelectedRepository - should set the selected repositories for the variable - idempotency test' {
- { Set-GitHubVariableSelectedRepository -Owner $owner -Name $variablePrefix -RepositoryID $repo.id, $repo2.id, $repo3.id } |
+ { Set-GitHubVariableSelectedRepository -Owner $owner -Name $orgVariableName -RepositoryID $repo.id, $repo2.id, $repo3.id } |
Should -Not -Throw
}
It 'Get-GitHubVariableSelectedRepository - gets 3 repository' {
- $result = Get-GitHubVariableSelectedRepository -Owner $owner -Name $variablePrefix
- LogGroup "SelectedRepositories - [$variablePrefix]" {
+ $result = Get-GitHubVariableSelectedRepository -Owner $owner -Name $orgVariableName
+ LogGroup "SelectedRepositories - [$orgVariableName]" {
Write-Host "$($result | Select-Object * | Format-Table | Out-String)"
}
$result | Should -Not -BeNullOrEmpty
@@ -316,9 +316,9 @@ Describe 'Variables' {
BeforeAll {
$scope = @{
Owner = $owner
- Repository = $repoName
+ Repository = $repo
}
- Set-GitHubVariable @scope -Name $variablePrefix -Value 'repository'
+ Set-GitHubVariable @scope -Name $orgVariableName -Value 'repository'
}
It 'Set-GitHubVariable' {
$name = "$variablePrefix`TestVariable"
@@ -435,16 +435,16 @@ Describe 'Variables' {
BeforeAll {
$scope = @{
Owner = $owner
- Repository = $repoName
+ Repository = $repo
}
- Set-GitHubVariable @scope -Name $variablePrefix -Value 'repository'
+ Set-GitHubVariable @scope -Name $orgVariableName -Value 'repository'
$scope = @{
Owner = $owner
- Repository = $repoName
+ Repository = $repo
Environment = $environmentName
}
- Set-GitHubEnvironment -Owner $owner -Repository $repoName -Name $environmentName
- Set-GitHubVariable @scope -Name $variablePrefix -Value 'environment'
+ Set-GitHubEnvironment -Owner $owner -Repository $repo -Name $environmentName
+ Set-GitHubVariable @scope -Name $orgVariableName -Value 'environment'
}
It 'Set-GitHubVariable' {
$name = "$variablePrefix`TestVariable"