コード例 #1
0
ファイル: platform_test.go プロジェクト: pedrosnk/tsuru
func (s *PlatformSuite) TestPlatformRemoveAlwaysRemoveFromDB(c *check.C) {
	provisioner := provisiontest.ExtensibleFakeProvisioner{
		FakeProvisioner: provisiontest.NewFakeProvisioner(),
	}
	Provisioner = &provisioner
	defer func() {
		Provisioner = s.provisioner
	}()
	conn, err := db.Conn()
	c.Assert(err, check.IsNil)
	defer conn.Close()
	err = PlatformRemove("platform_dont_exists")
	c.Assert(err, check.NotNil)
	name := "test_platform_update"
	args := make(map[string]string)
	args["dockerfile"] = "http://localhost/Dockerfile"
	err = PlatformAdd(provision.PlatformOptions{Name: name})
	c.Assert(err, check.IsNil)
	provisioner.PlatformRemove(name)
	defer conn.Platforms().Remove(bson.M{"_id": name})
	err = PlatformRemove(name)
	c.Assert(err, check.IsNil)
	count, err := conn.Platforms().Find(bson.M{"_id": name}).Count()
	c.Assert(err, check.IsNil)
	c.Assert(count, check.Equals, 0)
}
コード例 #2
0
ファイル: platform_test.go プロジェクト: pedrosnk/tsuru
func (s *PlatformSuite) TestPlatformAddDuplicate(c *check.C) {
	provisioner := provisiontest.ExtensibleFakeProvisioner{
		FakeProvisioner: provisiontest.NewFakeProvisioner(),
	}
	Provisioner = &provisioner
	defer func() {
		Provisioner = s.provisioner
	}()
	conn, err := db.Conn()
	c.Assert(err, check.IsNil)
	defer conn.Close()
	name := "test_platform_add"
	args := make(map[string]string)
	args["dockerfile"] = "http://localhost/Dockerfile"
	err = PlatformAdd(provision.PlatformOptions{Name: name, Args: args})
	defer conn.Platforms().Remove(bson.M{"_id": name})
	c.Assert(err, check.IsNil)
	provisioner.PlatformRemove(name)
	err = PlatformAdd(provision.PlatformOptions{Name: name, Args: args})
	c.Assert(err, check.Equals, DuplicatePlatformError)
}
コード例 #3
0
ファイル: platform_test.go プロジェクト: pedrosnk/tsuru
func (s *PlatformSuite) TestPlatformAddWithProvisionerError(c *check.C) {
	provisioner := provisiontest.ExtensibleFakeProvisioner{
		FakeProvisioner: provisiontest.NewFakeProvisioner(),
	}
	provisioner.PrepareFailure("PlatformAdd", errors.New("build error"))
	Provisioner = &provisioner
	defer func() {
		Provisioner = s.provisioner
	}()
	conn, err := db.Conn()
	c.Assert(err, check.IsNil)
	defer conn.Close()
	name := "test_platform_add"
	args := make(map[string]string)
	args["dockerfile"] = "http://localhost/Dockerfile"
	err = PlatformAdd(provision.PlatformOptions{Name: name, Args: args})
	defer conn.Platforms().Remove(bson.M{"_id": name})
	c.Assert(err, check.NotNil)
	count, err := conn.Platforms().FindId(name).Count()
	c.Assert(err, check.IsNil)
	c.Assert(count, check.Equals, 0)
}
コード例 #4
0
func (s *PlatformSuite) TestPlatformAdd(c *check.C) {
	provisioner := provisiontest.ExtensibleFakeProvisioner{
		FakeProvisioner: provisiontest.NewFakeProvisioner(),
	}
	Provisioner = &provisioner
	defer func() {
		Provisioner = s.provisioner
	}()
	conn, err := db.Conn()
	c.Assert(err, check.IsNil)
	defer conn.Close()
	name := "test_platform_add"
	args := make(map[string]string)
	args["dockerfile"] = "http://localhost/Dockerfile"
	err = PlatformAdd(name, args, nil)
	defer conn.Platforms().Remove(bson.M{"_id": name})
	c.Assert(err, check.IsNil)
	platform := provisioner.GetPlatform(name)
	c.Assert(platform.Name, check.Equals, name)
	c.Assert(platform.Args, check.DeepEquals, args)
	c.Assert(platform.Version, check.Equals, 1)
}