c5d36eaa2f
This PR continues the cleanup of the command package, removing linter warnings, refactoring to use helpers, making tests easier to read, etc.
28 lines
590 B
Go
28 lines
590 B
Go
package command
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/hashicorp/nomad/ci"
|
|
"github.com/mitchellh/cli"
|
|
"github.com/shoenig/test/must"
|
|
)
|
|
|
|
func TestAgentCheckCommand_ServerHealth(t *testing.T) {
|
|
ci.Parallel(t)
|
|
srv, _, url := testServer(t, false, nil)
|
|
defer stopTestAgent(srv)
|
|
|
|
ui := cli.NewMockUi()
|
|
cmd := &AgentCheckCommand{Meta: Meta{Ui: ui}}
|
|
address := fmt.Sprintf("-address=%s", url)
|
|
|
|
code := cmd.Run([]string{address})
|
|
must.Eq(t, HealthPass, code)
|
|
|
|
minPeers := fmt.Sprintf("-min-peers=%v", 3)
|
|
code = cmd.Run([]string{address, minPeers})
|
|
must.Eq(t, HealthCritical, code)
|
|
}
|