Ejemplo n.º 1
0
func (s *actionSuite) TestAction(c *gc.C) {

	var actionTests = []struct {
		description string
		action      params.Action
	}{{
		description: "A simple Action.",
		action: params.Action{
			Name:   "snapshot",
			Params: basicParams,
		},
	}, {
		description: "An Action with nested parameters.",
		action: params.Action{
			Name: "backup",
			Params: map[string]interface{}{
				"outfile": "foo.bz2",
				"compression": map[string]interface{}{
					"kind":    "bzip",
					"quality": float64(5.0),
				},
			},
		},
	}}

	for i, actionTest := range actionTests {
		c.Logf("test %d: %s", i, actionTest.description)
		a, err := s.uniterSuite.wordpressUnit.AddAction(
			actionTest.action.Name,
			actionTest.action.Params)
		c.Assert(err, gc.IsNil)

		actionTag := names.JoinActionTag(s.uniterSuite.wordpressUnit.Name(), i)
		c.Assert(a.Tag(), gc.Equals, actionTag)

		retrievedAction, err := s.uniter.Action(actionTag)
		c.Assert(err, gc.IsNil)

		c.Assert(retrievedAction.Name(), gc.DeepEquals, actionTest.action.Name)
		c.Assert(retrievedAction.Params(), gc.DeepEquals, actionTest.action.Params)
	}
}
Ejemplo n.º 2
0
func (s *actionSuite) TestActionNotFound(c *gc.C) {
	_, err := s.uniter.Action(names.JoinActionTag("wordpress/0", 0))
	c.Assert(err, gc.NotNil)
	c.Assert(err, gc.ErrorMatches, "action .*wordpress/0[^0-9]+0[^0-9]+ not found")
}
Ejemplo n.º 3
0
// ActionTag returns an ActionTag constructed from this action's
// Prefix and Sequence
func (a *Action) ActionTag() names.ActionTag {
	return names.JoinActionTag(a.Prefix(), a.Sequence())
}