Skip to content

Commit

Permalink
Add mock for Get-JiraField
Browse files Browse the repository at this point in the history
  • Loading branch information
hmmwhatsthisdo committed Aug 13, 2024
1 parent 0815b91 commit 141c466
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion Tests/Functions/Set-JiraIssue.Unit.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,32 @@ Describe "Set-JiraIssue" -Tag 'Unit' {
return $object
}

Mock Get-JiraField {

$(If ($null -eq $Field) {
@(
'Project'
'IssueType'
'Priority'
'Summary'
'Description'
'Reporter'
'CustomField'
'customfield_12345'
'customfield_67890'
'customfield_111222'
)
} Else {
$Field
}) | % {
$object = [PSCustomObject] @{
'Id' = $_
}
$object.PSObject.TypeNames.Insert(0, 'JiraPS.Field')
$object
}
}

Mock Resolve-JiraIssueObject -ModuleName JiraPS {
Get-JiraIssue -Key $Issue
}
Expand All @@ -73,7 +99,7 @@ Describe "Set-JiraIssue" -Tag 'Unit' {
# actually try to query a JIRA instance
Mock Invoke-JiraMethod {
ShowMockInfo 'Invoke-JiraMethod' 'Method', 'Uri'
throw "Unidentified call to Invoke-JiraMethod"
throw "Unidentified call ($Method $Uri) to Invoke-JiraMethod"
}

Context "Sanity checking" {
Expand Down

0 comments on commit 141c466

Please sign in to comment.