github.com/hernad/nomad@v1.6.112/command/check_test.go (about)

     1  // Copyright (c) HashiCorp, Inc.
     2  // SPDX-License-Identifier: MPL-2.0
     3  
     4  package command
     5  
     6  import (
     7  	"fmt"
     8  	"testing"
     9  
    10  	"github.com/hernad/nomad/ci"
    11  	"github.com/mitchellh/cli"
    12  	"github.com/shoenig/test/must"
    13  )
    14  
    15  func TestAgentCheckCommand_ServerHealth(t *testing.T) {
    16  	ci.Parallel(t)
    17  	srv, _, url := testServer(t, false, nil)
    18  	defer srv.Shutdown()
    19  
    20  	ui := cli.NewMockUi()
    21  	cmd := &AgentCheckCommand{Meta: Meta{Ui: ui}}
    22  	address := fmt.Sprintf("-address=%s", url)
    23  
    24  	code := cmd.Run([]string{address})
    25  	must.Eq(t, HealthPass, code)
    26  
    27  	minPeers := fmt.Sprintf("-min-peers=%v", 3)
    28  	code = cmd.Run([]string{address, minPeers})
    29  	must.Eq(t, HealthCritical, code)
    30  }