greenhost image links: {}

This commit is contained in:
Kiara Grouwstra 2022-08-15 23:52:09 +02:00
parent 45ddb4ae9f
commit 0646c0fc9d
2 changed files with 8 additions and 4 deletions

View File

@ -73,7 +73,7 @@ type imageRoot struct {
type imagesRoot struct {
Images []Image
Links []*LinkAction `json:"links"`
Links *Links `json:"links"`
Meta *Meta `json:"meta"`
}
@ -234,7 +234,11 @@ func (s *ImagesServiceOp) list(ctx context.Context, opt *ListOptions, listOpt *l
return nil, resp, err
}
if l := root.Links; l != nil {
resp.Links = l
var wrappedActions []*LinkAction
for _, element := range (*l).Actions {
wrappedActions = append(wrappedActions, &element)
}
resp.Links = wrappedActions
}
if m := root.Meta; m != nil {
resp.Meta = m

View File

@ -221,7 +221,7 @@ func TestImages_ListImagesMultiplePages(t *testing.T) {
mux.HandleFunc("/v2/images", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, http.MethodGet)
fmt.Fprint(w, `{"images": [{"id": "1"},{"id": "2"}], "links":[]}`)
fmt.Fprint(w, `{"images": [{"id": "1"},{"id": "2"}], "links":{}}`)
})
_, _, err := client.Images.List(ctx, &ListOptions{Page: 2})
@ -237,7 +237,7 @@ func TestImages_RetrievePageByNumber(t *testing.T) {
jBlob := `
{
"images": [{"id": "1"},{"id": "2"}],
"links":[]
"links":{}
}`
mux.HandleFunc("/v2/images", func(w http.ResponseWriter, r *http.Request) {