Skip to content

Commit

Permalink
Fix ListBatchJobs unit-test for Go 1.23+ (#6547)
Browse files Browse the repository at this point in the history
This happened because our assumption of dates in CLI is always UTC, but we
did't ask for this explicitely.
  • Loading branch information
dkrotx authored Dec 10, 2024
1 parent b08852b commit 4f05e8a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions tools/cli/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -553,11 +553,11 @@ func timestampPtrToStringPtr(unixNanoPtr *int64, onlyTime bool) *string {
if unixNanoPtr == nil {
return nil
}
return common.StringPtr(convertTime(*unixNanoPtr, onlyTime))
return common.StringPtr(timestampToString(*unixNanoPtr, onlyTime))
}

func convertTime(unixNano int64, onlyTime bool) string {
t := time.Unix(0, unixNano)
func timestampToString(unixNano int64, onlyTime bool) string {
t := time.Unix(0, unixNano).UTC()
var result string
if onlyTime {
result = t.Format(defaultTimeFormat)
Expand Down
4 changes: 2 additions & 2 deletions tools/cli/workflow_batch_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,14 @@ func ListBatchJobs(c *cli.Context) error {
for _, wf := range resp.Executions {
job := map[string]string{
"jobID": wf.Execution.GetWorkflowID(),
"startTime": convertTime(wf.GetStartTime(), false),
"startTime": timestampToString(wf.GetStartTime(), false),
"reason": string(wf.Memo.Fields["Reason"]),
"operator": string(wf.SearchAttributes.IndexedFields["Operator"]),
}

if wf.CloseStatus != nil {
job["status"] = wf.CloseStatus.String()
job["closeTime"] = convertTime(wf.GetCloseTime(), false)
job["closeTime"] = timestampToString(wf.GetCloseTime(), false)
} else {
job["status"] = "RUNNING"
}
Expand Down
10 changes: 5 additions & 5 deletions tools/cli/workflow_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func showHistoryHelper(c *cli.Context, wid, rid string) error {
if printRawTime {
columns = append(columns, strconv.FormatInt(e.GetTimestamp(), 10))
} else if printDateTime {
columns = append(columns, convertTime(e.GetTimestamp(), false))
columns = append(columns, timestampToString(e.GetTimestamp(), false))
}
if printVersion {
columns = append(columns, fmt.Sprintf("(Version: %v)", e.Version))
Expand Down Expand Up @@ -604,9 +604,9 @@ func printWorkflowProgress(c *cli.Context, domain, wid, rid string) error {
isTimeElapseExist = false
}
if showDetails {
fmt.Printf(" %d, %s, %s, %s\n", event.ID, convertTime(event.GetTimestamp(), false), ColorEvent(event), HistoryEventToString(event, true, maxFieldLength))
fmt.Printf(" %d, %s, %s, %s\n", event.ID, timestampToString(event.GetTimestamp(), false), ColorEvent(event), HistoryEventToString(event, true, maxFieldLength))
} else {
fmt.Printf(" %d, %s, %s\n", event.ID, convertTime(event.GetTimestamp(), false), ColorEvent(event))
fmt.Printf(" %d, %s, %s\n", event.ID, timestampToString(event.GetTimestamp(), false), ColorEvent(event))
}
lastEvent = event
}
Expand Down Expand Up @@ -1177,8 +1177,8 @@ func convertDescribeWorkflowExecutionResponse(resp *types.DescribeWorkflowExecut
executionInfo := workflowExecutionInfo{
Execution: info.Execution,
Type: info.Type,
StartTime: common.StringPtr(convertTime(info.GetStartTime(), false)),
CloseTime: common.StringPtr(convertTime(info.GetCloseTime(), false)),
StartTime: common.StringPtr(timestampToString(info.GetStartTime(), false)),
CloseTime: common.StringPtr(timestampToString(info.GetCloseTime(), false)),
CloseStatus: info.CloseStatus,
HistoryLength: info.HistoryLength,
ParentDomainID: info.ParentDomainID,
Expand Down

0 comments on commit 4f05e8a

Please sign in to comment.