open-vault/command/seal_status_test.go
Mitchell Hashimoto ab722a5ec2 fix all tests
2015-03-15 17:10:33 -07:00

37 lines
692 B
Go

package command
import (
"testing"
"github.com/hashicorp/vault/http"
"github.com/hashicorp/vault/vault"
"github.com/mitchellh/cli"
)
func TestSealStatus(t *testing.T) {
ui := new(cli.MockUi)
c := &SealStatusCommand{
Meta: Meta{
Ui: ui,
},
}
core := vault.TestCore(t)
key := vault.TestCoreInit(t, core)
ln, addr := http.TestServer(t, core)
defer ln.Close()
args := []string{"-address", addr}
if code := c.Run(args); code != 1 {
t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String())
}
if _, err := core.Unseal(key); err != nil {
t.Fatalf("err: %s", err)
}
if code := c.Run(args); code != 0 {
t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String())
}
}