~juju-qa/ubuntu/xenial/juju/xenial-2.0-beta3

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/resource/api/server/upload_test.go

  • Committer: Martin Packman
  • Date: 2016-03-30 19:31:08 UTC
  • mfrom: (1.1.41)
  • Revision ID: martin.packman@canonical.com-20160330193108-h9iz3ak334uk0z5r
Merge new upstream source 2.0~beta3

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
        })
70
70
}
71
71
 
 
72
func (s *UploadSuite) TestExtensionMismatch(c *gc.C) {
 
73
        content := "<some data>"
 
74
 
 
75
        // newResource returns a resource with a Path = name + ".tgz"
 
76
        res, _ := newResource(c, "spam", "a-user", content)
 
77
        stored, _ := newResource(c, "spam", "", "")
 
78
        s.data.ReturnGetResource = stored
 
79
        s.data.ReturnSetResource = res
 
80
        uh := server.UploadHandler{
 
81
                Username: "a-user",
 
82
                Store:    s.data,
 
83
        }
 
84
        req, _ := newUploadRequest(c, "spam", "a-service", content)
 
85
        req.Header.Set("Content-Disposition", "form-data; filename=different.ext")
 
86
 
 
87
        _, err := uh.HandleRequest(req)
 
88
        c.Assert(err, gc.ErrorMatches, `incorrect extension on resource upload "different.ext", expected ".tgz"`)
 
89
}
 
90
 
72
91
func (s *UploadSuite) TestHandleRequestPending(c *gc.C) {
73
92
        content := "<some data>"
74
93
        res, _ := newResource(c, "spam", "a-user", content)
237
256
        req.Header.Set("Content-Type", "application/octet-stream")
238
257
        req.Header.Set("Content-Length", fmt.Sprint(len(content)))
239
258
        req.Header.Set("Content-SHA384", fp.String())
 
259
        req.Header.Set("Content-Disposition", "form-data; filename="+name+".tgz")
240
260
 
241
261
        return req, body
242
262
}