Skip to content

Commit

Permalink
Gives RTT class a more Go-like name.
Browse files Browse the repository at this point in the history
  • Loading branch information
James Phillips committed Oct 23, 2015
1 parent 99cfbb8 commit 439110f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
12 changes: 6 additions & 6 deletions command/rtt.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import (
"github.com/mitchellh/cli"
)

// RttCommand is a Command implementation that allows users to query the
// RTTCommand is a Command implementation that allows users to query the
// estimated round trip time between nodes using network coordinates.
type RttCommand struct {
type RTTCommand struct {
Ui cli.Ui
}

func (c *RttCommand) Help() string {
func (c *RTTCommand) Help() string {
helpText := `
Usage: consul rtt [options] node1 [node2]
Expand Down Expand Up @@ -44,7 +44,7 @@ Options:
return strings.TrimSpace(helpText)
}

func (c *RttCommand) Run(args []string) int {
func (c *RTTCommand) Run(args []string) int {
var wan bool

cmdFlags := flag.NewFlagSet("rtt", flag.ContinueOnError)
Expand All @@ -56,7 +56,7 @@ func (c *RttCommand) Run(args []string) int {
return 1
}

// They must provide a pair of nodes.
// They must provide at least one node.
nodes := cmdFlags.Args()
if len(nodes) < 1 || len(nodes) > 2 {
c.Ui.Error("One or two node names must be specified")
Expand Down Expand Up @@ -179,6 +179,6 @@ SHOW_RTT:
return 0
}

func (c *RttCommand) Synopsis() string {
func (c *RTTCommand) Synopsis() string {
return "Estimates network round trip time between nodes"
}
24 changes: 12 additions & 12 deletions command/rtt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import (
"github.com/mitchellh/cli"
)

func TestRttCommand_Implements(t *testing.T) {
var _ cli.Command = &RttCommand{}
func TestRTTCommand_Implements(t *testing.T) {
var _ cli.Command = &RTTCommand{}
}

func TestRttCommand_Run_BadArgs(t *testing.T) {
func TestRTTCommand_Run_BadArgs(t *testing.T) {
ui := new(cli.MockUi)
c := &RttCommand{Ui: ui}
c := &RTTCommand{Ui: ui}

if code := c.Run([]string{}); code != 1 {
t.Fatalf("expected return code 1, got %d", code)
Expand All @@ -41,7 +41,7 @@ func TestRttCommand_Run_BadArgs(t *testing.T) {
}
}

func TestRttCommand_Run_LAN(t *testing.T) {
func TestRTTCommand_Run_LAN(t *testing.T) {
updatePeriod := 10 * time.Millisecond
a := testAgentWithConfig(t, func(c *agent.Config) {
c.ConsulConfig.CoordinateUpdatePeriod = updatePeriod
Expand Down Expand Up @@ -80,7 +80,7 @@ func TestRttCommand_Run_LAN(t *testing.T) {
// Try two known nodes.
{
ui := new(cli.MockUi)
c := &RttCommand{Ui: ui}
c := &RTTCommand{Ui: ui}
args := []string{
"-http-addr=" + a.httpAddr,
a.config.NodeName,
Expand All @@ -101,7 +101,7 @@ func TestRttCommand_Run_LAN(t *testing.T) {
// Default to the agent's node.
{
ui := new(cli.MockUi)
c := &RttCommand{Ui: ui}
c := &RTTCommand{Ui: ui}
args := []string{
"-http-addr=" + a.httpAddr,
"dogs",
Expand All @@ -121,7 +121,7 @@ func TestRttCommand_Run_LAN(t *testing.T) {
// Try an unknown node.
{
ui := new(cli.MockUi)
c := &RttCommand{Ui: ui}
c := &RTTCommand{Ui: ui}
args := []string{
"-http-addr=" + a.httpAddr,
a.config.NodeName,
Expand All @@ -134,7 +134,7 @@ func TestRttCommand_Run_LAN(t *testing.T) {
}
}

func TestRttCommand_Run_WAN(t *testing.T) {
func TestRTTCommand_Run_WAN(t *testing.T) {
a := testAgent(t)
defer a.Shutdown()
waitForLeader(t, a.httpAddr)
Expand All @@ -145,7 +145,7 @@ func TestRttCommand_Run_WAN(t *testing.T) {
// node with itself.
{
ui := new(cli.MockUi)
c := &RttCommand{Ui: ui}
c := &RTTCommand{Ui: ui}
args := []string{
"-wan",
"-http-addr=" + a.httpAddr,
Expand All @@ -166,7 +166,7 @@ func TestRttCommand_Run_WAN(t *testing.T) {
// Default to the agent's node.
{
ui := new(cli.MockUi)
c := &RttCommand{Ui: ui}
c := &RTTCommand{Ui: ui}
args := []string{
"-wan",
"-http-addr=" + a.httpAddr,
Expand All @@ -186,7 +186,7 @@ func TestRttCommand_Run_WAN(t *testing.T) {
// Try an unknown node.
{
ui := new(cli.MockUi)
c := &RttCommand{Ui: ui}
c := &RTTCommand{Ui: ui}
args := []string{
"-wan",
"-http-addr=" + a.httpAddr,
Expand Down
2 changes: 1 addition & 1 deletion commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func init() {
},

"rtt": func() (cli.Command, error) {
return &command.RttCommand{
return &command.RTTCommand{
Ui: ui,
}, nil
},
Expand Down

0 comments on commit 439110f

Please sign in to comment.