Beispiel #1
0
func assertGet(c *gc.C, stor storage.ResourceStorage, path, expected string) {
	r, err := stor.Get(path)
	c.Assert(err, gc.IsNil)
	defer r.Close()
	data, err := ioutil.ReadAll(r)
	c.Assert(err, gc.IsNil)
	c.Assert(data, gc.DeepEquals, []byte(expected))
}
Beispiel #2
0
func assertPut(c *gc.C, stor storage.ResourceStorage, path, data string) {
	r := strings.NewReader(data)
	checksum, err := stor.Put(path, r, int64(len(data)))
	c.Assert(err, gc.IsNil)
	md5Hash := md5.New()
	_, err = md5Hash.Write([]byte(data))
	c.Assert(err, gc.IsNil)
	c.Assert(checksum, gc.Equals, hex.EncodeToString(md5Hash.Sum(nil)))
	assertGet(c, stor, path, data)
}