2016-04-10 08:45:10 +00:00
|
|
|
package command
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/mitchellh/cli"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestAgentCheckCommand_ServerHealth(t *testing.T) {
|
2017-07-21 04:24:21 +00:00
|
|
|
t.Parallel()
|
2017-07-21 04:07:32 +00:00
|
|
|
srv, _, url := testServer(t, false, nil)
|
|
|
|
defer srv.Shutdown()
|
2016-04-10 08:45:10 +00:00
|
|
|
|
|
|
|
ui := new(cli.MockUi)
|
|
|
|
cmd := &AgentCheckCommand{Meta: Meta{Ui: ui}}
|
|
|
|
address := fmt.Sprintf("-address=%s", url)
|
|
|
|
|
|
|
|
code := cmd.Run([]string{address})
|
|
|
|
if code != HealthPass {
|
|
|
|
t.Fatalf("expected exit: %v, actual: %d", HealthPass, code)
|
|
|
|
}
|
|
|
|
|
|
|
|
minPeers := fmt.Sprintf("-min-peers=%v", 3)
|
|
|
|
code = cmd.Run([]string{address, minPeers})
|
|
|
|
if code != HealthCritical {
|
|
|
|
t.Fatalf("expected exitcode: %v, actual: %v", HealthCritical, code)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|