mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-25 08:21:07 -06:00
Output duration in UiHook after successful operation completion.
This commit is contained in:
parent
fa154bbb48
commit
817d1c4869
@ -243,8 +243,8 @@ func (h *UiHook) PostApply(
|
||||
}
|
||||
|
||||
colorized := h.Colorize.Color(fmt.Sprintf(
|
||||
"[reset][bold]%s: %s%s[reset]",
|
||||
id, msg, stateIdSuffix))
|
||||
"[reset][bold]%s: %s after %s%s[reset]",
|
||||
id, msg, time.Now().Round(time.Second).Sub(state.Start), stateIdSuffix))
|
||||
|
||||
h.ui.Output(colorized)
|
||||
|
||||
|
@ -2,6 +2,7 @@ package command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@ -173,10 +174,10 @@ func TestUiHookPostApply_emptyState(t *testing.T) {
|
||||
t.Fatalf("Expected hook to continue, given: %#v", action)
|
||||
}
|
||||
|
||||
expectedOutput := "data.google_compute_zones.available: Destruction complete\n"
|
||||
expectedRegexp := "^data.google_compute_zones.available: Destruction complete after -?[a-z0-9.]+\n$"
|
||||
output := ui.OutputWriter.String()
|
||||
if output != expectedOutput {
|
||||
t.Fatalf("Output didn't match.\nExpected: %q\nGiven: %q", expectedOutput, output)
|
||||
if matched, _ := regexp.MatchString(expectedRegexp, output); !matched {
|
||||
t.Fatalf("Output didn't match regexp.\nExpected: %q\nGiven: %q", expectedRegexp, output)
|
||||
}
|
||||
|
||||
expectedErrOutput := ""
|
||||
|
Loading…
Reference in New Issue
Block a user