github.com/blixtra/nomad@v0.7.2-0.20171221000451-da9a1d7bb050/command/check_test.go (about) 1 package command 2 3 import ( 4 "fmt" 5 "testing" 6 7 "github.com/mitchellh/cli" 8 ) 9 10 func TestAgentCheckCommand_ServerHealth(t *testing.T) { 11 t.Parallel() 12 srv, _, url := testServer(t, false, nil) 13 defer srv.Shutdown() 14 15 ui := new(cli.MockUi) 16 cmd := &AgentCheckCommand{Meta: Meta{Ui: ui}} 17 address := fmt.Sprintf("-address=%s", url) 18 19 code := cmd.Run([]string{address}) 20 if code != HealthPass { 21 t.Fatalf("expected exit: %v, actual: %d", HealthPass, code) 22 } 23 24 minPeers := fmt.Sprintf("-min-peers=%v", 3) 25 code = cmd.Run([]string{address, minPeers}) 26 if code != HealthCritical { 27 t.Fatalf("expected exitcode: %v, actual: %v", HealthCritical, code) 28 } 29 30 }