open-vault/command/status_test.go

40 lines
762 B
Go
Raw Normal View History

2015-03-13 18:33:17 +00:00
package command
import (
"testing"
"github.com/hashicorp/vault/http"
2016-04-01 17:16:05 +00:00
"github.com/hashicorp/vault/meta"
2015-03-13 18:33:17 +00:00
"github.com/hashicorp/vault/vault"
"github.com/mitchellh/cli"
)
2015-04-20 19:11:21 +00:00
func TestStatus(t *testing.T) {
2015-03-13 18:33:17 +00:00
ui := new(cli.MockUi)
2015-04-20 19:11:21 +00:00
c := &StatusCommand{
2016-04-01 17:16:05 +00:00
Meta: meta.Meta{
2015-03-13 18:33:17 +00:00
Ui: ui,
},
}
core := vault.TestCore(t)
2017-01-17 20:43:10 +00:00
keys, _ := vault.TestCoreInit(t, core)
2015-03-13 18:33:17 +00:00
ln, addr := http.TestServer(t, core)
defer ln.Close()
args := []string{"-address", addr}
if code := c.Run(args); code != 2 {
2015-03-13 18:33:17 +00:00
t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String())
}
2017-01-17 20:43:10 +00:00
for _, key := range keys {
if _, err := core.Unseal(key); err != nil {
t.Fatalf("err: %s", err)
}
2015-03-13 18:33:17 +00:00
}
if code := c.Run(args); code != 0 {
t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String())
}
}