Fix issue with command returning true when no rover was spawned

This commit is contained in:
Marc Di Luzio 2020-06-06 00:18:41 +01:00
parent 9c0dde616b
commit e242fcc4f7
2 changed files with 6 additions and 3 deletions

View file

@ -41,7 +41,7 @@ func Test_InnerMain(t *testing.T) {
assert.NoError(t, InnerMain("register")) assert.NoError(t, InnerMain("register"))
// We've not spawned a rover yet so these should fail // We've not spawned a rover yet so these should fail
// assert.Error(t, InnerMain("command")) // Currently not erroring, needs investigation assert.Error(t, InnerMain("command")) // Currently not erroring, needs investigation
assert.Error(t, InnerMain("radar")) assert.Error(t, InnerMain("radar"))
assert.Error(t, InnerMain("rover")) assert.Error(t, InnerMain("rover"))

View file

@ -75,8 +75,11 @@ func (a *Accountant) AssignRover(account uuid.UUID, rover uuid.UUID) error {
// GetRover gets the rover rover for the account // GetRover gets the rover rover for the account
func (a *Accountant) GetRover(account uuid.UUID) (uuid.UUID, error) { func (a *Accountant) GetRover(account uuid.UUID) (uuid.UUID, error) {
// Find the account matching the ID // Find the account matching the ID
if this, ok := a.Accounts[account]; ok { if this, ok := a.Accounts[account]; !ok {
return uuid.UUID{}, fmt.Errorf("no account found for id: %s", account)
} else if this.Rover == uuid.Nil {
return uuid.UUID{}, fmt.Errorf("no rover spawned for account %s", account)
} else {
return this.Rover, nil return this.Rover, nil
} }
return uuid.UUID{}, fmt.Errorf("no account found for id: %s", account)
} }