Skip to content

Commit

Permalink
FLPROD-796: Fixing wrong response type for snippet update endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis Davydov committed Nov 12, 2024
1 parent 7289d6f commit 4d75e51
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 20 deletions.
3 changes: 3 additions & 0 deletions .changelog/3596.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
Wrong response type for Snippet update endpoint
```
4 changes: 2 additions & 2 deletions snippets.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func snippetMultipartBody(request SnippetRequest) (string, *bytes.Buffer, error)
return mw.Boundary(), body, nil
}

func (api *API) UpdateZoneSnippet(ctx context.Context, rc *ResourceContainer, params SnippetRequest) ([]Snippet, error) {
func (api *API) UpdateZoneSnippet(ctx context.Context, rc *ResourceContainer, params SnippetRequest) (*Snippet, error) {
if rc.Identifier == "" {
return nil, ErrMissingZoneID
}
Expand All @@ -153,7 +153,7 @@ func (api *API) UpdateZoneSnippet(ctx context.Context, rc *ResourceContainer, pa
return nil, err
}

result := SnippetsResponse{}
result := SnippetResponse{}
if err := json.Unmarshal(res, &result); err != nil {
return nil, fmt.Errorf("%s: %w", errUnmarshalError, err)
}
Expand Down
23 changes: 5 additions & 18 deletions snippets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,12 @@ func TestUpdateSnippets(t *testing.T) {
assert.Equal(t, http.MethodPut, r.Method, "Expected method 'PUT', got %s", r.Method)
w.Header().Set("content-type", "application/json")
fmt.Fprint(w, `{
"result": [
"result":
{
"snippet_name": "some_id_1",
"created_on":"0001-01-01T00:00:00Z",
"modified_on":"0001-01-01T00:00:00Z"
},
{
"snippet_name": "some_id_2",
"created_on":"0001-01-01T00:00:00Z",
"modified_on":"0001-01-01T00:00:00Z"
}
],
"success": true,
"errors": [],
"messages": []
Expand All @@ -149,17 +143,10 @@ func TestUpdateSnippets(t *testing.T) {
},
},
}
want := []Snippet{
{
SnippetName: "some_id_1",
CreatedOn: &time.Time{},
ModifiedOn: &time.Time{},
},
{
SnippetName: "some_id_2",
CreatedOn: &time.Time{},
ModifiedOn: &time.Time{},
},
want := &Snippet{
SnippetName: "some_id_1",
CreatedOn: &time.Time{},
ModifiedOn: &time.Time{},
}
zoneActual, err := client.UpdateZoneSnippet(context.Background(), ZoneIdentifier(testZoneID), toUpdate)
if assert.NoError(t, err) {
Expand Down

0 comments on commit 4d75e51

Please sign in to comment.