Пример #1
0
// RemoveTools deletes all tools from the supplied storage.
func RemoveTools(c *C, storage environs.Storage) {
	names, err := storage.List("tools/juju-")
	c.Assert(err, IsNil)
	c.Logf("removing files: %v", names)
	for _, name := range names {
		err = storage.Remove(name)
		c.Check(err, IsNil)
	}
}
Пример #2
0
func checkRemoveAll(c *C, storage environs.Storage) {
	contents := []byte("File contents.")
	aFile := "a-file.txt"
	err := storage.Put(aFile, bytes.NewBuffer(contents), int64(len(contents)))
	c.Assert(err, IsNil)
	err = storage.Put("empty-file", bytes.NewBuffer(nil), 0)
	c.Assert(err, IsNil)

	err = storage.RemoveAll()
	c.Assert(err, IsNil)

	files, err := storage.List("")
	c.Assert(err, IsNil)
	c.Check(files, HasLen, 0)

	_, err = storage.Get(aFile)
	c.Assert(err, NotNil)
	c.Check(err, ErrorMatches, fmt.Sprintf("file %q not found", aFile))
}