示例#1
0
func (s *GitDeployerSuite) SetUpTest(c *gc.C) {
	s.GitSuite.SetUpTest(c)
	s.bundles = &bundleReader{}
	s.targetPath = filepath.Join(c.MkDir(), "target")
	deployerPath := filepath.Join(c.MkDir(), "deployer")
	s.deployer = charm.NewGitDeployer(s.targetPath, deployerPath, s.bundles)
}
示例#2
0
func (s *ConverterSuite) TestNewDeployerCreatesGitDeployerOnceStaged(c *gc.C) {
	gitDeployer := charm.NewGitDeployer(s.targetPath, s.dataPath, s.bundles)
	info := s.bundles.AddBundle(c, charmURL(1), mockBundle{})
	err := gitDeployer.Stage(info, nil)
	c.Assert(err, gc.IsNil)

	deployer, err := charm.NewDeployer(s.targetPath, s.dataPath, s.bundles)
	c.Assert(err, gc.IsNil)
	c.Assert(deployer, jc.Satisfies, charm.IsGitDeployer)
}
示例#3
0
func (s *ConverterSuite) TestConvertGitDeployerBeforeDeploy(c *gc.C) {
	gitDeployer := charm.NewGitDeployer(s.targetPath, s.dataPath, s.bundles)
	info := s.bundles.AddBundle(c, charmURL(1), mockBundle{})
	err := gitDeployer.Stage(info, nil)
	c.Assert(err, gc.IsNil)

	deployer, err := charm.NewDeployer(s.targetPath, s.dataPath, s.bundles)
	c.Assert(err, gc.IsNil)
	err = charm.FixDeployer(&deployer)
	c.Assert(err, gc.IsNil)
	c.Assert(deployer, jc.Satisfies, charm.IsManifestDeployer)
	ft.Removed{"current"}.Check(c, s.dataPath)

	err = deployer.Stage(info, nil)
	c.Assert(err, gc.IsNil)
	err = deployer.Deploy()
	c.Assert(err, gc.IsNil)
	ft.Removed{".git"}.Check(c, s.targetPath)
}
示例#4
0
func (s *ConverterSuite) TestPathological(c *gc.C) {
	initial := s.bundles.AddCustomBundle(c, charmURL(1), func(path string) {
		ft.File{"common", "initial", 0644}.Create(c, path)
		ft.File{"initial", "blah", 0644}.Create(c, path)
	})
	staged := s.bundles.AddCustomBundle(c, charmURL(2), func(path string) {
		ft.File{"common", "staged", 0644}.Create(c, path)
		ft.File{"user", "badwrong", 0644}.Create(c, path)
	})
	final := s.bundles.AddCustomBundle(c, charmURL(3), func(path string) {
		ft.File{"common", "final", 0644}.Create(c, path)
		ft.File{"final", "blah", 0644}.Create(c, path)
	})

	gitDeployer := charm.NewGitDeployer(s.targetPath, s.dataPath, s.bundles)
	err := gitDeployer.Stage(initial, nil)
	c.Assert(err, gc.IsNil)
	err = gitDeployer.Deploy()
	c.Assert(err, gc.IsNil)

	preserveUser := ft.File{"user", "preserve", 0644}.Create(c, s.targetPath)
	err = gitDeployer.Stage(staged, nil)
	c.Assert(err, gc.IsNil)

	deployer, err := charm.NewDeployer(s.targetPath, s.dataPath, s.bundles)
	c.Assert(err, gc.IsNil)
	err = charm.FixDeployer(&deployer)
	c.Assert(err, gc.IsNil)

	err = deployer.Stage(final, nil)
	c.Assert(err, gc.IsNil)
	err = deployer.Deploy()
	c.Assert(err, gc.IsNil)
	ft.Removed{".git"}.Check(c, s.targetPath)
	ft.Removed{"initial"}.Check(c, s.targetPath)
	ft.Removed{"staged"}.Check(c, s.targetPath)
	ft.File{"common", "final", 0644}.Check(c, s.targetPath)
	preserveUser.Check(c, s.targetPath)
}