File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,11 @@ function Add-JiraIssueWorklog {
73
73
Write-Error @errorMessage
74
74
}
75
75
76
+ # Harmonize DateStarted:
77
+ # `Get-Date -Date "01.01.2000"` does not return the local timezone
78
+ # which is required by the API
79
+ $DateStarted = [DateTime ]::new($DateStarted.Ticks , ' Local' )
80
+
76
81
$requestBody = @ {
77
82
' comment' = $Comment
78
83
# We need to fix the date with a RegEx replace because the API does not like:
Original file line number Diff line number Diff line change @@ -103,7 +103,7 @@ Describe "Add-JiraIssueWorklog" -Tag 'Unit' {
103
103
}
104
104
105
105
Mock Invoke-JiraMethod - ModuleName JiraPS - ParameterFilter {$Method -eq ' POST' -and $URI -eq " $jiraServer /rest/api/latest/issue/$issueID /worklog" } {
106
- ShowMockInfo ' Invoke-JiraMethod' ' Method' , ' Uri'
106
+ ShowMockInfo ' Invoke-JiraMethod' ' Method' , ' Uri' , ' Body '
107
107
ConvertFrom-Json $restResponse
108
108
}
109
109
@@ -136,5 +136,15 @@ Describe "Add-JiraIssueWorklog" -Tag 'Unit' {
136
136
Assert-MockCalled - CommandName Get-JiraIssue - ModuleName JiraPS - Exactly - Times 2 - Scope It
137
137
Assert-MockCalled - CommandName Invoke-JiraMethod - ModuleName JiraPS - Exactly - Times 1 - Scope It
138
138
}
139
+
140
+ It " formats DateStarted independetly of the input" {
141
+ Add-JiraIssueWorklog - Comment ' This is a test worklog entry from Pester.' - Issue $issueKey - TimeSpent " 00:10:00" - DateStarted " 2018-01-01"
142
+ Add-JiraIssueWorklog - Comment ' This is a test worklog entry from Pester.' - Issue $issueKey - TimeSpent " 00:10:00" - DateStarted (Get-Date )
143
+ Add-JiraIssueWorklog - Comment ' This is a test worklog entry from Pester.' - Issue $issueKey - TimeSpent " 00:10:00" - DateStarted (Get-Date - Date " 01.01.2000" )
144
+
145
+ Assert-MockCalled - CommandName Invoke-JiraMethod - ModuleName JiraPS - ParameterFilter {
146
+ $Body -match ' \"started\":\s*"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}[\+\-]\d{4}"'
147
+ } - Exactly - Times 3 - Scope It
148
+ }
139
149
}
140
150
}
You can’t perform that action at this time.
0 commit comments