Output duration in UiHook after successful operation completion.

This commit is contained in:
Michael Handler 2017-07-13 13:01:19 -07:00 committed by Martin Atkins
parent fa154bbb48
commit 817d1c4869
2 changed files with 6 additions and 5 deletions

View File

@ -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)

View File

@ -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 := ""