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(
|
colorized := h.Colorize.Color(fmt.Sprintf(
|
||||||
"[reset][bold]%s: %s%s[reset]",
|
"[reset][bold]%s: %s after %s%s[reset]",
|
||||||
id, msg, stateIdSuffix))
|
id, msg, time.Now().Round(time.Second).Sub(state.Start), stateIdSuffix))
|
||||||
|
|
||||||
h.ui.Output(colorized)
|
h.ui.Output(colorized)
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ package command
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"regexp"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -173,10 +174,10 @@ func TestUiHookPostApply_emptyState(t *testing.T) {
|
||||||
t.Fatalf("Expected hook to continue, given: %#v", action)
|
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()
|
output := ui.OutputWriter.String()
|
||||||
if output != expectedOutput {
|
if matched, _ := regexp.MatchString(expectedRegexp, output); !matched {
|
||||||
t.Fatalf("Output didn't match.\nExpected: %q\nGiven: %q", expectedOutput, output)
|
t.Fatalf("Output didn't match regexp.\nExpected: %q\nGiven: %q", expectedRegexp, output)
|
||||||
}
|
}
|
||||||
|
|
||||||
expectedErrOutput := ""
|
expectedErrOutput := ""
|
||||||
|
|
Loading…
Reference in New Issue