diff --git a/pkg/accounts/accounts.go b/pkg/accounts/accounts.go index 1ce4ec7..e975a08 100644 --- a/pkg/accounts/accounts.go +++ b/pkg/accounts/accounts.go @@ -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 { diff --git a/pkg/accounts/accounts_test.go b/pkg/accounts/accounts_test.go index 275cde3..bef693f 100644 --- a/pkg/accounts/accounts_test.go +++ b/pkg/accounts/accounts_test.go @@ -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) diff --git a/pkg/rove/rove_test.go b/pkg/rove/rove_test.go index 35cd8c3..d5362dd 100644 --- a/pkg/rove/rove_test.go +++ b/pkg/rove/rove_test.go @@ -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")