From f3f0b19b333e7301bfa51cdeff9a7a0bc50f9695 Mon Sep 17 00:00:00 2001 From: Thomas Gummerer Date: Mon, 29 Apr 2024 05:46:36 -0300 Subject: [PATCH] be consistent in the way we round seconds (#16070) In some cases we only display full seconds, particularly when rendering the summary event, and when converting the engine event for use in the API. However we are currently not consistent with that, rounding up in the display code and rounding down when converting the engine event. It probably doesn't matter what exactly we are doing here, but for writing display snapshot tests it does. Let's split the difference here, and always round up, so we never give the impression that the operation took no time. It doesn't look like Pulumi Cloud shows this at all, so it probably doesn't matter for users, and we could just round up for everyone as well. I don't have strong opinions about that. --- pkg/backend/display/events.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/backend/display/events.go b/pkg/backend/display/events.go index a9c23ba4e919..c383561eda9c 100644 --- a/pkg/backend/display/events.go +++ b/pkg/backend/display/events.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "math" "regexp" "time" @@ -134,7 +135,7 @@ func ConvertEngineEvent(e engine.Event, showSecrets bool) (apitype.EngineEvent, } apiEvent.SummaryEvent = &apitype.SummaryEvent{ MaybeCorrupt: p.MaybeCorrupt, - DurationSeconds: int(p.Duration.Seconds()), + DurationSeconds: int(math.Ceil(p.Duration.Seconds())), ResourceChanges: changes, PolicyPacks: p.PolicyPacks, }