Skip to content

Commit

Permalink
Fix up tidy test
Browse files Browse the repository at this point in the history
  • Loading branch information
jefferai committed Jun 14, 2018
1 parent 28166fa commit 99c1244
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions vault/expiration_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package vault

import (
"bytes"
"context"
"fmt"
"reflect"
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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())
Expand Down

0 comments on commit 99c1244

Please sign in to comment.