Rename "commands" to "command"
This commit is contained in:
parent
1554b7c21b
commit
ea4b7de4ac
8 changed files with 159 additions and 159 deletions
|
@ -83,7 +83,7 @@ func TestServer_Command(t *testing.T) {
|
|||
err := serv.Request("POST", "register", &rove.RegisterRequest{Name: acc}, &rove.RegisterResponse{})
|
||||
assert.NoError(t, err, "First register attempt should pass")
|
||||
|
||||
err = serv.Request("POST", "commands", &rove.CommandsRequest{
|
||||
err = serv.Request("POST", "command", &rove.CommandRequest{
|
||||
Account: acc,
|
||||
Commands: []*rove.Command{
|
||||
{
|
||||
|
@ -91,7 +91,7 @@ func TestServer_Command(t *testing.T) {
|
|||
Bearing: "NE",
|
||||
},
|
||||
},
|
||||
}, &rove.CommandsResponse{})
|
||||
}, &rove.CommandResponse{})
|
||||
assert.NoError(t, err, "Commands should should pass")
|
||||
}
|
||||
|
||||
|
|
|
@ -109,8 +109,8 @@ func (s *Server) Radar(ctx context.Context, req *rove.RadarRequest) (*rove.Radar
|
|||
return response, nil
|
||||
}
|
||||
|
||||
// Commands issues commands to the world based on a gRPC request
|
||||
func (s *Server) Commands(ctx context.Context, req *rove.CommandsRequest) (*rove.CommandsResponse, error) {
|
||||
// Command issues commands to the world based on a gRPC request
|
||||
func (s *Server) Command(ctx context.Context, req *rove.CommandRequest) (*rove.CommandResponse, error) {
|
||||
if len(req.Account) == 0 {
|
||||
return nil, fmt.Errorf("empty account")
|
||||
}
|
||||
|
@ -130,5 +130,5 @@ func (s *Server) Commands(ctx context.Context, req *rove.CommandsRequest) (*rove
|
|||
return nil, err
|
||||
}
|
||||
|
||||
return &rove.CommandsResponse{}, nil
|
||||
return &rove.CommandResponse{}, nil
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ func printUsage() {
|
|||
fmt.Fprintln(os.Stderr, "\nCommands")
|
||||
fmt.Fprintln(os.Stderr, "\tserver-status prints the server status")
|
||||
fmt.Fprintln(os.Stderr, "\tregister NAME registers an account and stores it (use with -name)")
|
||||
fmt.Fprintln(os.Stderr, "\tcommands COMMAND [VAL...] issue commands to rover, accepts multiple, see below")
|
||||
fmt.Fprintln(os.Stderr, "\tcommand COMMAND [VAL...] issue commands to rover, accepts multiple, see below")
|
||||
fmt.Fprintln(os.Stderr, "\tradar gathers radar data for the current rover")
|
||||
fmt.Fprintln(os.Stderr, "\tstatus gets status info for current rover")
|
||||
fmt.Fprintln(os.Stderr, "\tconfig [HOST] outputs the local config info, optionally sets host")
|
||||
|
@ -196,7 +196,7 @@ func InnerMain(command string, args ...string) error {
|
|||
config.Account.Name = name
|
||||
}
|
||||
|
||||
case "commands":
|
||||
case "command":
|
||||
if len(args) == 0 {
|
||||
return fmt.Errorf("must pass commands to 'commands'")
|
||||
}
|
||||
|
@ -228,7 +228,7 @@ func InnerMain(command string, args ...string) error {
|
|||
}
|
||||
}
|
||||
|
||||
d := rove.CommandsRequest{
|
||||
d := rove.CommandRequest{
|
||||
Account: config.Account.Name,
|
||||
Commands: commands,
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ func InnerMain(command string, args ...string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
_, err := client.Commands(ctx, &d)
|
||||
_, err := client.Command(ctx, &d)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
|
|
|
@ -47,13 +47,13 @@ func Test_InnerMain(t *testing.T) {
|
|||
assert.NoError(t, InnerMain("status"))
|
||||
|
||||
// Commands should fail with no commands
|
||||
assert.Error(t, InnerMain("commands"))
|
||||
assert.Error(t, InnerMain("command"))
|
||||
|
||||
// Give it commands
|
||||
assert.NoError(t, InnerMain("commands", "move", "N"))
|
||||
assert.NoError(t, InnerMain("commands", "stash"))
|
||||
assert.NoError(t, InnerMain("commands", "repair"))
|
||||
assert.NoError(t, InnerMain("command", "move", "N"))
|
||||
assert.NoError(t, InnerMain("command", "stash"))
|
||||
assert.NoError(t, InnerMain("command", "repair"))
|
||||
|
||||
// Give it malformed commands
|
||||
assert.Error(t, InnerMain("commands", "move", "stash"))
|
||||
assert.Error(t, InnerMain("command", "move", "stash"))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue