← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~jtv/gomaasapi/check-for-filename into lp:gomaasapi

 

Jeroen T. Vermeulen has proposed merging lp:~jtv/gomaasapi/check-for-filename into lp:gomaasapi.

Commit message:
More neglected error-checking in the test service: empty or missing filenames.

Requested reviews:
  MAAS Maintainers (maas-maintainers)

For more details, see:
https://code.launchpad.net/~jtv/gomaasapi/check-for-filename/+merge/151406

This probably won't affect anyone in practice, but work on another project got held up because there *might* be a problem with a missing filename and I need to be sure.


Jeroen
-- 
https://code.launchpad.net/~jtv/gomaasapi/check-for-filename/+merge/151406
Your team MAAS Maintainers is requested to review the proposed merge of lp:~jtv/gomaasapi/check-for-filename into lp:gomaasapi.
=== modified file 'testservice.go'
--- testservice.go	2013-02-27 18:08:45 +0000
+++ testservice.go	2013-03-04 02:55:23 +0000
@@ -423,6 +423,9 @@
 	values, err := url.ParseQuery(r.URL.RawQuery)
 	checkError(err)
 	filename := values.Get("filename")
+	if filename == "" {
+		panic("upload has no filename")
+	}
 
 	uploads := r.MultipartForm.File
 	if len(uploads) != 1 {

=== modified file 'testservice_test.go'
--- testservice_test.go	2013-02-27 17:58:24 +0000
+++ testservice_test.go	2013-03-04 02:55:23 +0000
@@ -185,7 +185,8 @@
 	c.Check(err, IsNil)
 	c.Check(resp.StatusCode, Equals, http.StatusOK)
 	c.Check(len(suite.server.files), Equals, 1)
-	file, _ := suite.server.files["filename"]
+	file, ok := suite.server.files["filename"]
+	c.Assert(ok, Equals, true)
 	field, err := file.GetField("content")
 	c.Assert(err, IsNil)
 	c.Check(field, Equals, base64.StdEncoding.EncodeToString(fileContent))