Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
Comment thread
joseartrivera marked this conversation as resolved.
Outdated
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "PowerShell",
"request": "launch",
"name": "PowerShell Launch Current File",
"script": "${file}",
"args": [],
"cwd": "${file}"
},
{
"type": "PowerShell",
"request": "launch",
"name": "PowerShell Launch Current File in Temporary Console",
"script": "${file}",
"args": [],
"cwd": "${file}",
"createTemporaryIntegratedConsole": true
},
{
"type": "PowerShell",
"request": "launch",
"name": "PowerShell Launch Current File w/Args Prompt",
"script": "${file}",
"args": [
"${command:SpecifyScriptArgs}"
],
"cwd": "${file}"
},
{
"type": "PowerShell",
"request": "attach",
"name": "PowerShell Attach to Host Process",
"processId": "${command:PickPSHostProcess}",
"runspaceId": 1
},
{
"type": "PowerShell",
"request": "launch",
"name": "PowerShell Interactive Session",
"cwd": ""
}
]
}
27 changes: 15 additions & 12 deletions GitHubAssignees.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ function New-GithubAssignee
The OwnerName and RepositoryName will be extracted from here instead of needing to provide
them individually.

.PARAMETER IssueNumber
.PARAMETER Issue
Issue number to add the assignees to.

.PARAMETER Assignee
Expand Down Expand Up @@ -241,8 +241,9 @@ function New-GithubAssignee
[string] $Uri,

[Parameter(Mandatory)]
[int] $IssueNumber,
[int] $Issue,

[Parameter(Mandatory)]
[ValidateCount(1, 10)]
Comment thread
joseartrivera marked this conversation as resolved.
[string[]] $Assignee,

Expand All @@ -261,18 +262,18 @@ function New-GithubAssignee
'OwnerName' = (Get-PiiSafeString -PlainText $OwnerName)
'RepositoryName' = (Get-PiiSafeString -PlainText $RepositoryName)
'AssigneeCount' = $Assignee.Count
'IssueNumber' = (Get-PiiSafeString -PlainText $IssueNumber)
'Issue' = (Get-PiiSafeString -PlainText $Issue)
}

$hashBody = @{
'assignees' = $Assignee
}

$params = @{
'UriFragment' = "repos/$OwnerName/$RepositoryName/issues/$IssueNumber/assignees"
'Body' = ($hashBody | ConvertTo-Json)
'UriFragment' = "repos/$OwnerName/$RepositoryName/issues/$Issue/assignees"
'Body' = (ConvertTo-Json -InputObject $hashBody)
'Method' = 'Post'
'Description' = "Add assignees to issue $IssueNumber for $RepositoryName"
'Description' = "Add assignees to issue $Issue for $RepositoryName"
'AccessToken' = $AccessToken
Comment thread
joseartrivera marked this conversation as resolved.
'AcceptHeader' = 'application/vnd.github.symmetra-preview+json'
'TelemetryEventName' = $MyInvocation.MyCommand.Name
Expand Down Expand Up @@ -304,7 +305,7 @@ function Remove-GithubAssignee
The OwnerName and RepositoryName will be extracted from here instead of needing to provide
them individually.

.PARAMETER IssueNumber
.PARAMETER Issue
Issue number to remove the assignees from.

.PARAMETER Assignee
Expand Down Expand Up @@ -341,8 +342,10 @@ function Remove-GithubAssignee
ParameterSetName='Uri')]
[string] $Uri,

[int] $IssueNumber,
[Parameter(Mandatory)]
[int] $Issue,

[Parameter(Mandatory)]
[string[]] $Assignee,

[string] $AccessToken,
Expand All @@ -360,18 +363,18 @@ function Remove-GithubAssignee
'OwnerName' = (Get-PiiSafeString -PlainText $OwnerName)
'RepositoryName' = (Get-PiiSafeString -PlainText $RepositoryName)
'AssigneeCount' = $Assignee.Count
'IssueNumber' = (Get-PiiSafeString -PlainText $IssueNumber)
'Issue' = (Get-PiiSafeString -PlainText $Issue)
}

$hashBody = @{
'assignees' = $Assignee
}

$params = @{
'UriFragment' = "repos/$OwnerName/$RepositoryName/issues/$IssueNumber/assignees"
'Body' = ($hashBody | ConvertTo-Json)
'UriFragment' = "repos/$OwnerName/$RepositoryName/issues/$Issue/assignees"
'Body' = (ConvertTo-Json -InputObject $hashBody)
'Method' = 'Delete'
'Description' = "Removing assignees from issue $IssueNumber for $RepositoryName"
'Description' = "Removing assignees from issue $Issue for $RepositoryName"
'AccessToken' = $AccessToken
Comment thread
joseartrivera marked this conversation as resolved.
'AcceptHeader' = 'application/vnd.github.symmetra-preview+json'
'TelemetryEventName' = $MyInvocation.MyCommand.Name
Expand Down
82 changes: 44 additions & 38 deletions Tests/GitHubAssignees.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -70,59 +70,65 @@ if (-not $script:accessTokenConfigured)
# Backup the user's configuration before we begin, and ensure we're at a pure state before running
# the tests. We'll restore it at the end.
$configFile = New-TemporaryFile
Comment thread
joseartrivera marked this conversation as resolved.
Backup-GitHubConfiguration -Path $configFile
Reset-GitHubConfiguration
try
{
Backup-GitHubConfiguration -Path $configFile
Reset-GitHubConfiguration
Set-GitHubConfiguration -DisableTelemetry # We don't want UT's to impact telemetry

$repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid) -AutoInit
$issue = New-GitHubIssue -Uri $repo.svn_url -Title "Test issue"
$repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid) -AutoInit
$issue = New-GitHubIssue -Uri $repo.svn_url -Title "Test issue"

Describe 'Getting a valid assignee' {
Describe 'Getting a valid assignee' {

Context 'For getting a valid assignee' {
$assigneeList = @(Get-GitHubAssignee -Uri $repo.svn_url)
Context 'For getting a valid assignee' {
$assigneeList = @(Get-GitHubAssignee -Uri $repo.svn_url)

It 'Should have returned the one assignee' {
$assigneeList.Count | Should be 1
}
It 'Should have returned the one assignee' {
$assigneeList.Count | Should be 1
}

$assigneeUserName = $assigneeList[0].login
$assigneeUserName = $assigneeList[0].login

It 'Should have returned an assignee with a login'{
$assigneeUserName | Should not be $null
}
It 'Should have returned an assignee with a login'{
$assigneeUserName | Should not be $null
}

$hasPermission = Test-GitHubAssignee -Uri $repo.svn_url -Assignee $assigneeUserName
$hasPermission = Test-GitHubAssignee -Uri $repo.svn_url -Assignee $assigneeUserName

It 'Should have returned an assignee with permission to be assigned to an issue'{
$hasPermission | Should be $true
}
It 'Should have returned an assignee with permission to be assigned to an issue'{
$hasPermission | Should be $true
}

}
}
}

Describe 'Adding and removing an assignee to an issue'{
Describe 'Adding and removing an assignee to an issue'{

Context 'For adding an assignee to an issue'{
$assigneeList = @(Get-GitHubAssignee -Uri $repo.svn_url)
$assigneeUserName = $assigneeList[0].login
$assignees = @($assigneeUserName)
New-GithubAssignee -Uri $repo.svn_url -IssueNumber $issue.number -Assignee $assignees
$issue = Get-GitHubIssue -Uri $repo.svn_url -Issue $issue.number
Context 'For adding an assignee to an issue'{
$assigneeList = @(Get-GitHubAssignee -Uri $repo.svn_url)
$assigneeUserName = $assigneeList[0].login
$assignees = @($assigneeUserName)
New-GithubAssignee -Uri $repo.svn_url -Issue $issue.number -Assignee $assignees
$issue = Get-GitHubIssue -Uri $repo.svn_url -Issue $issue.number

It 'Should have assigned the user to the issue' {
$issue.assignee.login | Should be $assigneeUserName
}
It 'Should have assigned the user to the issue' {
$issue.assignee.login | Should be $assigneeUserName
}

Remove-GithubAssignee -Uri $repo.svn_url -IssueNumber $issue.number -Assignee $assignees
$issue = Get-GitHubIssue -Uri $repo.svn_url -Issue $issue.number
Remove-GithubAssignee -Uri $repo.svn_url -Issue $issue.number -Assignee $assignees
$issue = Get-GitHubIssue -Uri $repo.svn_url -Issue $issue.number

It 'Should have removed the user from issue' {
$issue.assignees.Count | Should be 0
It 'Should have removed the user from issue' {
$issue.assignees.Count | Should be 0
}
}
}
}

Remove-GitHubRepository -Uri $repo.svn_url

# Restore the user's configuration to its pre-test state
Restore-GitHubConfiguration -Path $configFile
Remove-GitHubRepository -Uri $repo.svn_url
}
finally
{
# Restore the user's configuration to its pre-test state
Restore-GitHubConfiguration -Path $configFile
}
4 changes: 2 additions & 2 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -364,10 +364,10 @@ $HasPermission = Test-GitHubAssignee -OwnerName Powershell -RepositoryName Power

#### Add assignee to an issue
```powershell
New-GithubAssignee -OwnerName Powershell -RepositoryName PowerShellForGitHub -Assignees $assignees
New-GithubAssignee -OwnerName Powershell -RepositoryName PowerShellForGitHub -Assignees $assignees -Issue 1
```

#### Remove assignee from an issue
```powershell
Remove-GithubAssignee -OwnerName Powershell -RepositoryName PowerShellForGitHub -Assignees $assignees
Remove-GithubAssignee -OwnerName Powershell -RepositoryName PowerShellForGitHub -Assignees $assignees -Issue 1
```