From 99c124487c596f532c390fe794c07dd2e67fa89c Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Wed, 13 Jun 2018 21:24:38 -0400 Subject: [PATCH] Fix up tidy test --- vault/expiration_test.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/vault/expiration_test.go b/vault/expiration_test.go index e0b93ec43bc8..b4997e6a08e9 100644 --- a/vault/expiration_test.go +++ b/vault/expiration_test.go @@ -1,6 +1,7 @@ package vault import ( + "bytes" "context" "fmt" "reflect" @@ -38,6 +39,14 @@ func TestExpiration_Tidy(t *testing.T) { var err error exp := mockExpiration(t) + + // We use this later for tidy testing where we need to check the output + logOut := new(bytes.Buffer) + logger := log.New(&log.LoggerOptions{ + Output: logOut, + }) + exp.logger = logger + if err := exp.Restore(nil); err != nil { t.Fatal(err) } @@ -212,9 +221,11 @@ func TestExpiration_Tidy(t *testing.T) { } } - if !(err1 != nil && err1.Error() == "tidy operation on leases is already in progress") && - !(err2 != nil && err2.Error() == "tidy operation on leases is already in progress") { - t.Fatalf("expected at least one of err1 or err2 to be set; err1: %#v\n err2:%#v\n", err1, err2) + if err1 != nil || err2 != nil { + t.Fatalf("got an error: err1: %v; err2: %v", err1, err2) + } + if !strings.Contains(logOut.String(), "tidy operation on leases is already in progress") { + t.Fatalf("expected to see a warning saying operation in progress, output is %s", logOut.String()) } root, err := exp.tokenStore.rootToken(context.Background())