Skip to content

Commit

Permalink
SizeGigaBytes is an floating-point number.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewsomething committed Nov 30, 2016
1 parent bec8984 commit 7242cde
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion snapshots.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type Snapshot struct {
ResourceType string `json:"resource_type,omitempty"`
Regions []string `json:"regions,omitempty"`
MinDiskSize int `json:"min_disk_size,omitempty"`
SizeGigaBytes int `json:"size_gigabytes,omitempty"`
SizeGigaBytes float64 `json:"size_gigabytes,omitempty"`
Created string `json:"created_at,omitempty"`
}

Expand Down
12 changes: 6 additions & 6 deletions snapshots_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ func TestSnapshots_List(t *testing.T) {

mux.HandleFunc("/v2/snapshots", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
fmt.Fprint(w, `{"snapshots":[{"id":"1"},{"id":"2"}]}`)
fmt.Fprint(w, `{"snapshots":[{"id":"1"},{"id":"2", "size_gigabytes": 4.84}]}`)
})

snapshots, _, err := client.Snapshots.List(nil)
if err != nil {
t.Errorf("Snapshots.List returned error: %v", err)
}

expected := []Snapshot{{ID: "1"}, {ID: "2"}}
expected := []Snapshot{{ID: "1"}, {ID: "2", SizeGigaBytes: 4.84}}
if !reflect.DeepEqual(snapshots, expected) {
t.Errorf("Snapshots.List returned %+v, expected %+v", snapshots, expected)
}
Expand Down Expand Up @@ -64,15 +64,15 @@ func TestSnapshots_ListDroplet(t *testing.T) {
t.Errorf("'resource_type' query = %v, expected %v", actual, expected)
}

fmt.Fprint(w, `{"snapshots":[{"id":"1"},{"id":"2"}]}`)
fmt.Fprint(w, `{"snapshots":[{"id":"1"},{"id":"2", "size_gigabytes": 4.84}]}`)
})

snapshots, _, err := client.Snapshots.ListDroplet(nil)
if err != nil {
t.Errorf("Snapshots.ListDroplet returned error: %v", err)
}

expected := []Snapshot{{ID: "1"}, {ID: "2"}}
expected := []Snapshot{{ID: "1"}, {ID: "2", SizeGigaBytes: 4.84}}
if !reflect.DeepEqual(snapshots, expected) {
t.Errorf("Snapshots.ListDroplet returned %+v, expected %+v", snapshots, expected)
}
Expand Down Expand Up @@ -167,12 +167,12 @@ func TestSnapshot_String(t *testing.T) {
ResourceType: "droplet",
Regions: []string{"one"},
MinDiskSize: 20,
SizeGigaBytes: 0,
SizeGigaBytes: 4.84,
Created: "2013-11-27T09:24:55Z",
}

stringified := snapshot.String()
expected := `godo.Snapshot{ID:"1", Name:"Snapsh176ot", ResourceID:"0", ResourceType:"droplet", Regions:["one"], MinDiskSize:20, SizeGigaBytes:0, Created:"2013-11-27T09:24:55Z"}`
expected := `godo.Snapshot{ID:"1", Name:"Snapsh176ot", ResourceID:"0", ResourceType:"droplet", Regions:["one"], MinDiskSize:20, SizeGigaBytes:4.84, Created:"2013-11-27T09:24:55Z"}`
if expected != stringified {
t.Errorf("Snapshot.String returned %+v, expected %+v", stringified, expected)
}
Expand Down

0 comments on commit 7242cde

Please sign in to comment.