func (*copySuite) TestCopy(c *gc.C) { for i, test := range copyTests { c.Logf("test %d: %v", i, test.about) src, dst := c.MkDir(), c.MkDir() test.src.Create(c, src) test.dst.Create(c, dst) path := test.src[0].GetPath() err := fs.Copy( filepath.Join(src, path), filepath.Join(dst, path), ) if test.err != "" { c.Check(err, gc.ErrorMatches, test.err) } else { c.Assert(err, gc.IsNil) test.src.Check(c, dst) } } }
func (u *UpgradeMongoCommand) rollbackCopyBackup(dataDir, origin string) error { if err := u.mongoStop(); err != nil { return errors.Annotate(err, "cannot stop mongo to rollback") } defer u.mongoStart() dbDir := filepath.Join(dataDir, "db") if err := u.remove(dbDir); err != nil { return errors.Annotate(err, "could not remove the existing folder to rollback") } if err := fs.Copy(origin, dbDir); err != nil { return errors.Annotate(err, "cannot rollback mongo database") } if err := u.rollbackAgentConfig(); err != nil { return errors.Annotate(err, "cannot roo back agent configuration") } return errors.Annotate(u.UpdateService(true), "cannot rollback service script") }
func (s *ContextSuite) SetCharm(c *gc.C, name string) { err := os.RemoveAll(s.paths.GetCharmDir()) c.Assert(err, jc.ErrorIsNil) err = fs.Copy(testcharms.Repo.CharmDirPath(name), s.paths.GetCharmDir()) c.Assert(err, jc.ErrorIsNil) }
func clone(dst, src string) string { dst = filepath.Join(dst, filepath.Base(src)) check(fs.Copy(src, dst)) return dst }
// RenamedClonedDirPath returns the path to a new copy of the default // charm directory named name, renamed to newName. func (r *Repo) RenamedClonedDirPath(dst, name, newName string) string { dstPath := filepath.Join(dst, newName) err := fs.Copy(r.CharmDirPath(name), dstPath) check(err) return dstPath }