Fix tests and actually use the account name
This commit is contained in:
parent
42534ac545
commit
4c76530832
3 changed files with 12 additions and 7 deletions
|
@ -47,6 +47,7 @@ func (a *Accountant) RegisterAccount(name string) (acc Account, err error) {
|
|||
|
||||
// Set the account ID to a new UUID
|
||||
acc.Id = uuid.New()
|
||||
acc.Name = name
|
||||
|
||||
// Verify this acount isn't already registered
|
||||
for _, a := range a.Accounts {
|
||||
|
|
|
@ -21,7 +21,7 @@ func TestAccountant_RegisterAccount(t *testing.T) {
|
|||
|
||||
// Start by making two accounts
|
||||
|
||||
namea := "one"
|
||||
namea := uuid.New().String()
|
||||
acca, err := accountant.RegisterAccount(namea)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
|
@ -29,7 +29,7 @@ func TestAccountant_RegisterAccount(t *testing.T) {
|
|||
t.Errorf("Missmatched account name after register, expected: %s, actual: %s", namea, acca.Name)
|
||||
}
|
||||
|
||||
nameb := "two"
|
||||
nameb := uuid.New().String()
|
||||
accb, err := accountant.RegisterAccount(nameb)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
|
@ -55,7 +55,7 @@ func TestAccountant_LoadSave(t *testing.T) {
|
|||
t.Error("New accountant created with non-zero account number")
|
||||
}
|
||||
|
||||
name := "one"
|
||||
name := uuid.New().String()
|
||||
a, err := accountant.RegisterAccount(name)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
|
@ -97,7 +97,7 @@ func TestAccountant_AssignPrimary(t *testing.T) {
|
|||
t.Error("New accountant created with non-zero account number")
|
||||
}
|
||||
|
||||
name := "one"
|
||||
name := uuid.New().String()
|
||||
a, err := accountant.RegisterAccount(name)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
|
|
|
@ -4,6 +4,8 @@ package rove
|
|||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
var serverUrl = "localhost:80"
|
||||
|
@ -23,7 +25,8 @@ func TestStatus(t *testing.T) {
|
|||
func TestRegister(t *testing.T) {
|
||||
conn := NewConnection(serverUrl)
|
||||
|
||||
reg1, err := conn.Register("one")
|
||||
a := uuid.New().String()
|
||||
reg1, err := conn.Register(a)
|
||||
if err != nil {
|
||||
t.Errorf("Register returned error: %s", err)
|
||||
} else if !reg1.Success {
|
||||
|
@ -32,7 +35,8 @@ func TestRegister(t *testing.T) {
|
|||
t.Error("Server returned empty registration ID")
|
||||
}
|
||||
|
||||
reg2, err := conn.Register("two")
|
||||
b := uuid.New().String()
|
||||
reg2, err := conn.Register(b)
|
||||
if err != nil {
|
||||
t.Errorf("Register returned error: %s", err)
|
||||
} else if !reg2.Success {
|
||||
|
@ -41,7 +45,7 @@ func TestRegister(t *testing.T) {
|
|||
t.Error("Server returned empty registration ID")
|
||||
}
|
||||
|
||||
if reg2, err := conn.Register("one"); err != nil {
|
||||
if reg2, err := conn.Register(a); err != nil {
|
||||
t.Errorf("Register returned error: %s", err)
|
||||
} else if reg2.Success {
|
||||
t.Error("Server should have failed to register duplicate name")
|
||||
|
|
Loading…
Add table
Reference in a new issue