Skip to content

Commit

Permalink
updated List response
Browse files Browse the repository at this point in the history
  • Loading branch information
imaskm committed Nov 27, 2024
1 parent 35b3a27 commit 96c363f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
6 changes: 3 additions & 3 deletions reserved_ipv6.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const reservedIPV6sBasePath = "v2/reserved_ipv6"
// ReservedIPV6sService is an interface for interfacing with the reserved IPV6s
// endpoints of the Digital Ocean API.
type ReservedIPV6sService interface {
List(context.Context, *ListOptions) (*ReservedIPV6List, *Response, error)
List(context.Context, *ListOptions) ([]ReservedIPV6, *Response, error)
Get(context.Context, string) (*ReservedIPV6Resp, *Response, error)
Create(context.Context, *ReservedIPV6CreateRequest) (*ReservedIPV6Resp, *Response, error)
Delete(context.Context, string) (*Response, error)
Expand Down Expand Up @@ -59,7 +59,7 @@ type ReservedIPV6CreateRequest struct {
}

// List all reserved IPV6s.
func (r *ReservedIPV6sServiceOp) List(ctx context.Context, opt *ListOptions) (*ReservedIPV6List, *Response, error) {
func (r *ReservedIPV6sServiceOp) List(ctx context.Context, opt *ListOptions) ([]ReservedIPV6, *Response, error) {
path := reservedIPV6sBasePath
path, err := addOptions(path, opt)
if err != nil {
Expand All @@ -83,7 +83,7 @@ func (r *ReservedIPV6sServiceOp) List(ctx context.Context, opt *ListOptions) (*R
resp.Links = root.Links
}

return root, resp, err
return root.ReservedIPV6s, resp, err
}

// Get an individual reserved IPv6.
Expand Down
11 changes: 5 additions & 6 deletions reserved_ipv6_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,12 @@ func TestReservedIPV6s_List(t *testing.T) {
t.Errorf("ReservedIPs.List returned error: %v", err)
}

expectedReservedIPs := ReservedIPV6List{
ReservedIPV6s: []ReservedIPV6{
{RegionSlug: "nyc3", Droplet: &Droplet{ID: 1}, IP: "2604:a880:800:14::42c3:d000"},
{RegionSlug: "nyc3", Droplet: &Droplet{ID: 2}, IP: "2604:a880:800:14::42c3:d001"},
},
expectedReservedIPs := []ReservedIPV6{
{RegionSlug: "nyc3", Droplet: &Droplet{ID: 1}, IP: "2604:a880:800:14::42c3:d000"},
{RegionSlug: "nyc3", Droplet: &Droplet{ID: 2}, IP: "2604:a880:800:14::42c3:d001"},
}
if !reflect.DeepEqual(reservedIPs.ReservedIPV6s, expectedReservedIPs.ReservedIPV6s) {

if !reflect.DeepEqual(reservedIPs, expectedReservedIPs) {
t.Errorf("ReservedIPV6s.List returned reserved IPs %+v, expected %+v", reservedIPs, expectedReservedIPs)
}

Expand Down

0 comments on commit 96c363f

Please sign in to comment.