Exemple #1
0
func testPasswordAPIResult(c *gc.C, result params.ErrorResult) error {
	facade, err := agent.NewConnFacade(passwordChecker(c, params.ErrorResults{
		Results: []params.ErrorResult{result},
	}))
	c.Assert(err, jc.ErrorIsNil)

	return facade.SetPassword(names.NewApplicationTag("omg"), "blah")
}
Exemple #2
0
func testLifeAPIResult(c *gc.C, result params.AgentGetEntitiesResult) (agent.Life, error) {
	facade, err := agent.NewConnFacade(lifeChecker(c, params.AgentGetEntitiesResults{
		Entities: []params.AgentGetEntitiesResult{result},
	}))
	c.Assert(err, jc.ErrorIsNil)

	return facade.Life(names.NewApplicationTag("omg"))
}
Exemple #3
0
func (s *FacadeSuite) TestSetPasswordNoResult(c *gc.C) {
	result := params.ErrorResults{}
	facade, err := agent.NewConnFacade(passwordChecker(c, result))
	c.Assert(err, jc.ErrorIsNil)

	err = facade.SetPassword(names.NewApplicationTag("omg"), "blah")
	c.Check(err, gc.ErrorMatches, "expected 1 result, got 0")
}
Exemple #4
0
func (s *FacadeSuite) TestLifeNoResult(c *gc.C) {
	result := params.AgentGetEntitiesResults{}
	facade, err := agent.NewConnFacade(lifeChecker(c, result))
	c.Assert(err, jc.ErrorIsNil)

	life, err := facade.Life(names.NewApplicationTag("omg"))
	c.Check(err, gc.ErrorMatches, "expected 1 result, got 0")
	c.Check(life, gc.Equals, agent.Life(""))
}
Exemple #5
0
func (s *FacadeSuite) TestLifeCallError(c *gc.C) {
	apiCaller := apiCaller(c, func(request string, arg, _ interface{}) error {
		c.Check(request, gc.Equals, "GetEntities")
		c.Check(arg, jc.DeepEquals, params.Entities{
			Entities: []params.Entity{{
				Tag: "application-omg",
			}},
		})
		return errors.New("splat")
	})
	facade, err := agent.NewConnFacade(apiCaller)
	c.Assert(err, jc.ErrorIsNil)

	life, err := facade.Life(names.NewApplicationTag("omg"))
	c.Check(err, gc.ErrorMatches, "splat")
	c.Check(life, gc.Equals, agent.Life(""))
}
Exemple #6
0
func (s *FacadeSuite) TestSetPasswordCallError(c *gc.C) {
	apiCaller := apiCaller(c, func(request string, arg, _ interface{}) error {
		c.Check(request, gc.Equals, "SetPasswords")
		c.Check(arg, jc.DeepEquals, params.EntityPasswords{
			Changes: []params.EntityPassword{{
				Tag:      "application-omg",
				Password: "******",
			}},
		})
		return errors.New("splat")
	})
	facade, err := agent.NewConnFacade(apiCaller)
	c.Assert(err, jc.ErrorIsNil)

	err = facade.SetPassword(names.NewApplicationTag("omg"), "seekr1t")
	c.Check(err, gc.ErrorMatches, "splat")
}