コード例 #1
0
ファイル: destroy_test.go プロジェクト: jameinel/core
func (s *DestroySuite) TestCannotGetInstances(c *gc.C) {
	env := &mockEnviron{
		allInstances: func() ([]instance.Instance, error) {
			return nil, fmt.Errorf("nope")
		},
	}
	err := common.Destroy(env)
	c.Assert(err, gc.ErrorMatches, "nope")
}
コード例 #2
0
ファイル: destroy_test.go プロジェクト: jameinel/core
func (s *DestroySuite) TestCannotTrashStorageWhenNoInstances(c *gc.C) {
	env := &mockEnviron{
		storage: &mockStorage{removeAllErr: fmt.Errorf("noes!")},
		allInstances: func() ([]instance.Instance, error) {
			return nil, environs.ErrNoInstances
		},
	}
	err := common.Destroy(env)
	c.Assert(err, gc.ErrorMatches, "noes!")
}
コード例 #3
0
ファイル: destroy_test.go プロジェクト: jameinel/core
func (s *DestroySuite) TestSuccessWhenNoInstances(c *gc.C) {
	stor := newStorage(s, c)
	err := stor.Put("elsewhere", strings.NewReader("stuff"), 5)
	c.Assert(err, gc.IsNil)

	env := &mockEnviron{
		storage: stor,
		allInstances: func() ([]instance.Instance, error) {
			return nil, environs.ErrNoInstances
		},
	}
	err = common.Destroy(env)
	c.Assert(err, gc.IsNil)
	_, err = stor.Get("elsewhere")
	c.Assert(err, jc.Satisfies, errors.IsNotFound)
}
コード例 #4
0
ファイル: destroy_test.go プロジェクト: jameinel/core
func (s *DestroySuite) TestCannotStopInstances(c *gc.C) {
	env := &mockEnviron{
		allInstances: func() ([]instance.Instance, error) {
			return []instance.Instance{
				&mockInstance{id: "one"},
				&mockInstance{id: "another"},
			}, nil
		},
		stopInstances: func(instances []instance.Instance) error {
			c.Assert(instances, gc.HasLen, 2)
			c.Assert(instances[0].Id(), gc.Equals, instance.Id("one"))
			c.Assert(instances[1].Id(), gc.Equals, instance.Id("another"))
			return fmt.Errorf("nah")
		},
	}
	err := common.Destroy(env)
	c.Assert(err, gc.ErrorMatches, "nah")
}
コード例 #5
0
ファイル: destroy_test.go プロジェクト: jameinel/core
func (s *DestroySuite) TestSuccess(c *gc.C) {
	stor := newStorage(s, c)
	err := stor.Put("somewhere", strings.NewReader("stuff"), 5)
	c.Assert(err, gc.IsNil)

	env := &mockEnviron{
		storage: stor,
		allInstances: func() ([]instance.Instance, error) {
			return []instance.Instance{
				&mockInstance{id: "one"},
			}, nil
		},
		stopInstances: func(instances []instance.Instance) error {
			c.Assert(instances, gc.HasLen, 1)
			c.Assert(instances[0].Id(), gc.Equals, instance.Id("one"))
			return nil
		},
	}
	err = common.Destroy(env)
	c.Assert(err, gc.IsNil)
	_, err = stor.Get("somewhere")
	c.Assert(err, jc.Satisfies, errors.IsNotFound)
}
コード例 #6
0
ファイル: environ.go プロジェクト: jameinel/core
func (env *joyentEnviron) Destroy() error {
	return common.Destroy(env)
}