Add the /commands path to handle a set of commands
Entirely synchronous now but allows for the "move" command
This commit is contained in:
parent
e5d5d123a6
commit
e2857d7506
5 changed files with 169 additions and 19 deletions
|
@ -71,3 +71,12 @@ func (a *Accountant) AssignPrimary(account uuid.UUID, instance uuid.UUID) error
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetPrimary gets the primary instance for the account
|
||||
func (a *Accountant) GetPrimary(account uuid.UUID) (uuid.UUID, error) {
|
||||
// Find the account matching the ID
|
||||
if this, ok := a.Accounts[account]; ok {
|
||||
return this.Primary, nil
|
||||
}
|
||||
return uuid.UUID{}, fmt.Errorf("no account found for id: %s", account)
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ func TestAccountant_RegisterAccount(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestAccountant_AssignPrimary(t *testing.T) {
|
||||
func TestAccountant_AssignGetPrimary(t *testing.T) {
|
||||
accountant := NewAccountant()
|
||||
if len(accountant.Accounts) != 0 {
|
||||
t.Error("New accountant created with non-zero account number")
|
||||
|
@ -67,5 +67,9 @@ func TestAccountant_AssignPrimary(t *testing.T) {
|
|||
t.Error("Failed to set primary for created account")
|
||||
} else if accountant.Accounts[a.Id].Primary != inst {
|
||||
t.Error("Primary for assigned account is incorrect")
|
||||
} else if id, err := accountant.GetPrimary(a.Id); err != nil {
|
||||
t.Error("Failed to get primary for account")
|
||||
} else if id != inst {
|
||||
t.Error("Fetched primary is incorrect for account")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue