Skip to content

Commit

Permalink
Make unpackUpdateRequest method testable
Browse files Browse the repository at this point in the history
Due to the mux.Vars holding global state, we instead pass the vars to
the unpackUpdateRequesti, and that way make it easier to test.
  • Loading branch information
lilic committed Apr 2, 2018
1 parent 589b24e commit 274e4aa
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/rest/apisurface.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,8 @@ func (s *APISurface) UpdateHandler(w http.ResponseWriter, r *http.Request) {
return
}

request, err := unpackUpdateRequest(r)
v := mux.Vars(r)
request, err := unpackUpdateRequest(r, v)
if err != nil {
s.writeError(w, err, http.StatusInternalServerError)
return
Expand All @@ -418,13 +419,12 @@ func (s *APISurface) UpdateHandler(w http.ResponseWriter, r *http.Request) {
s.writeResponse(w, status, response)
}

func unpackUpdateRequest(r *http.Request) (*osb.UpdateInstanceRequest, error) {
func unpackUpdateRequest(r *http.Request, vars map[string]string) (*osb.UpdateInstanceRequest, error) {
osbRequest := &osb.UpdateInstanceRequest{}
if err := unmarshalRequestBody(r, osbRequest); err != nil {
return nil, err
}

vars := mux.Vars(r)
osbRequest.InstanceID = vars[osb.VarKeyInstanceID]

asyncQueryParamVal := r.FormValue(osb.AcceptsIncomplete)
Expand Down

0 comments on commit 274e4aa

Please sign in to comment.