Skip to content

Commit

Permalink
account: add name field. (#620)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewsomething committed Jul 18, 2023
1 parent 43f27da commit 4059082
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
1 change: 1 addition & 0 deletions account.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type Account struct {
ReservedIPLimit int `json:"reserved_ip_limit,omitempty"`
VolumeLimit int `json:"volume_limit,omitempty"`
Email string `json:"email,omitempty"`
Name string `json:"name,omitempty"`
UUID string `json:"uuid,omitempty"`
EmailVerified bool `json:"email_verified,omitempty"`
Status string `json:"status,omitempty"`
Expand Down
21 changes: 17 additions & 4 deletions account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func TestAccountGet(t *testing.T) {
"reserved_ip_limit": 25,
"volume_limit": 22,
"email": "sammy@digitalocean.com",
"name": "Sammy the Shark",
"uuid": "b6fr89dbf6d9156cace5f3c78dc9851d957381ef",
"email_verified": true
}
Expand All @@ -34,8 +35,16 @@ func TestAccountGet(t *testing.T) {
t.Errorf("Account.Get returned error: %v", err)
}

expected := &Account{DropletLimit: 25, FloatingIPLimit: 25, ReservedIPLimit: 25, Email: "sammy@digitalocean.com",
UUID: "b6fr89dbf6d9156cace5f3c78dc9851d957381ef", EmailVerified: true, VolumeLimit: 22}
expected := &Account{
DropletLimit: 25,
FloatingIPLimit: 25,
ReservedIPLimit: 25,
Email: "sammy@digitalocean.com",
Name: "Sammy the Shark",
UUID: "b6fr89dbf6d9156cace5f3c78dc9851d957381ef",
EmailVerified: true,
VolumeLimit: 22,
}
if !reflect.DeepEqual(acct, expected) {
t.Errorf("Account.Get returned %+v, expected %+v", acct, expected)
}
Expand All @@ -48,14 +57,15 @@ func TestAccountString(t *testing.T) {
ReservedIPLimit: 25,
VolumeLimit: 22,
Email: "sammy@digitalocean.com",
Name: "Sammy the Shark",
UUID: "b6fr89dbf6d9156cace5f3c78dc9851d957381ef",
EmailVerified: true,
Status: "active",
StatusMessage: "message",
}

stringified := acct.String()
expected := `godo.Account{DropletLimit:25, FloatingIPLimit:25, ReservedIPLimit:25, VolumeLimit:22, Email:"sammy@digitalocean.com", UUID:"b6fr89dbf6d9156cace5f3c78dc9851d957381ef", EmailVerified:true, Status:"active", StatusMessage:"message"}`
expected := `godo.Account{DropletLimit:25, FloatingIPLimit:25, ReservedIPLimit:25, VolumeLimit:22, Email:"sammy@digitalocean.com", Name:"Sammy the Shark", UUID:"b6fr89dbf6d9156cace5f3c78dc9851d957381ef", EmailVerified:true, Status:"active", StatusMessage:"message"}`
if expected != stringified {
t.Errorf("\n got %+v\nexpected %+v", stringified, expected)
}
Expand All @@ -75,6 +85,7 @@ func TestAccountGetWithTeam(t *testing.T) {
"floating_ip_limit": 25,
"volume_limit": 22,
"email": "sammy@digitalocean.com",
"name": "Sammy the Shark",
"uuid": "b6fr89dbf6d9156cace5f3c78dc9851d957381ef",
"email_verified": true,
"team": {
Expand All @@ -96,6 +107,7 @@ func TestAccountGetWithTeam(t *testing.T) {
DropletLimit: 25,
FloatingIPLimit: 25,
Email: "sammy@digitalocean.com",
Name: "Sammy the Shark",
UUID: "b6fr89dbf6d9156cace5f3c78dc9851d957381ef",
EmailVerified: true,
VolumeLimit: 22,
Expand All @@ -116,6 +128,7 @@ func TestAccountStringWithTeam(t *testing.T) {
ReservedIPLimit: 25,
VolumeLimit: 22,
Email: "sammy@digitalocean.com",
Name: "Sammy the Shark",
UUID: "b6fr89dbf6d9156cace5f3c78dc9851d957381ef",
EmailVerified: true,
Status: "active",
Expand All @@ -127,7 +140,7 @@ func TestAccountStringWithTeam(t *testing.T) {
}

stringified := acct.String()
expected := `godo.Account{DropletLimit:25, FloatingIPLimit:25, ReservedIPLimit:25, VolumeLimit:22, Email:"sammy@digitalocean.com", UUID:"b6fr89dbf6d9156cace5f3c78dc9851d957381ef", EmailVerified:true, Status:"active", StatusMessage:"message", Team:godo.TeamInfo{Name:"My Team", UUID:"b6fr89dbf6d9156cace5f3c78dc9851d957381ef"}}`
expected := `godo.Account{DropletLimit:25, FloatingIPLimit:25, ReservedIPLimit:25, VolumeLimit:22, Email:"sammy@digitalocean.com", Name:"Sammy the Shark", UUID:"b6fr89dbf6d9156cace5f3c78dc9851d957381ef", EmailVerified:true, Status:"active", StatusMessage:"message", Team:godo.TeamInfo{Name:"My Team", UUID:"b6fr89dbf6d9156cace5f3c78dc9851d957381ef"}}`
if expected != stringified {
t.Errorf("\n got %+v\nexpected %+v", stringified, expected)
}
Expand Down

0 comments on commit 4059082

Please sign in to comment.