Skip to content

Commit

Permalink
use "snap-path" in the form value for try mode (thanks Gustavo)
Browse files Browse the repository at this point in the history
  • Loading branch information
mvo5 committed May 27, 2016
1 parent 67d3968 commit 6dd6ade
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion client/snap_op.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func (client *Client) Try(path string, options *SnapOptions) (changeID string, e
buf := bytes.NewBuffer(nil)
mw := multipart.NewWriter(buf)
mw.WriteField("action", "try")
mw.WriteField("try", path)
mw.WriteField("snap-path", path)
mw.WriteField("devmode", strconv.FormatBool(options.DevMode))
mw.Close()

Expand Down
6 changes: 3 additions & 3 deletions client/snap_op_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ func (cs *clientSuite) TestClientOpTryMode(c *check.C) {
mr := multipart.NewReader(cs.req.Body, params["boundary"])
formData := formToMap(c, mr)
c.Check(formData, check.DeepEquals, map[string]string{
"action": "try",
"try": snapdir,
"devmode": strconv.FormatBool(opts.DevMode),
"action": "try",
"snap-path": snapdir,
"devmode": strconv.FormatBool(opts.DevMode),
})

c.Check(cs.req.Method, check.Equals, "POST")
Expand Down
2 changes: 1 addition & 1 deletion cmd/snap/cmd_snap_op_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func (s *SnapOpSuite) runTryTest(c *check.C, devmode bool) {
postData, err := ioutil.ReadAll(r.Body)
c.Assert(err, check.IsNil)
c.Assert(string(postData), check.Matches, "(?s).*Content-Disposition: form-data; name=\"action\"\r\n\r\ntry\r\n.*")
c.Assert(string(postData), check.Matches, fmt.Sprintf("(?s).*Content-Disposition: form-data; name=\"try\"\r\n\r\n%s\r\n.*", tryDir))
c.Assert(string(postData), check.Matches, fmt.Sprintf("(?s).*Content-Disposition: form-data; name=\"snap-path\"\r\n\r\n%s\r\n.*", tryDir))
c.Assert(string(postData), check.Matches, fmt.Sprintf("(?s).*Content-Disposition: form-data; name=\"devmode\"\r\n\r\n%s\r\n.*", strconv.FormatBool(devmode)))
}

Expand Down
6 changes: 3 additions & 3 deletions daemon/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -734,10 +734,10 @@ func sideloadSnap(c *Command, r *http.Request, user *auth.UserState) Response {
}

if len(form.Value["action"]) > 0 && form.Value["action"][0] == "try" {
if len(form.Value["try"]) == 0 {
return BadRequest("need 'try' value in form")
if len(form.Value["snap-path"]) == 0 {
return BadRequest("need 'snap-path' value in form")
}
return trySnap(c, r, user, form.Value["try"][0], flags)
return trySnap(c, r, user, form.Value["snap-path"][0], flags)
}

// find the file for the "snap" form field
Expand Down

0 comments on commit 6dd6ade

Please sign in to comment.