예제 #1
0
func (*ScaryConnectSuite) TestEntityUnknownLife(c *gc.C) {
	// "random" failure case
	stub := &testing.Stub{}
	expectConn := &mockConn{stub: stub}
	apiOpen := func(info *api.Info, opts api.DialOpts) (api.Connection, error) {
		return expectConn, nil
	}

	entity := names.NewServiceTag("omg")
	connect := func() (api.Connection, error) {
		return apicaller.ScaryConnect(&mockAgent{
			stub:   stub,
			model:  coretesting.ModelTag,
			entity: entity,
		}, apiOpen)
	}

	conn, err := lifeTest(c, stub, apiagent.Life("zombie"), connect)
	c.Check(conn, gc.IsNil)
	c.Check(err, gc.ErrorMatches, `unknown life value "zombie"`)
	stub.CheckCalls(c, []testing.StubCall{{
		FuncName: "Life",
		Args:     []interface{}{entity},
	}, {
		FuncName: "Close",
	}})
}
예제 #2
0
파일: facade_test.go 프로젝트: bac/juju
func (s *FacadeSuite) TestLifeUnknown(c *gc.C) {
	result := params.AgentGetEntitiesResult{
		Life: "revenant",
	}
	life, err := testLifeAPIResult(c, result)
	c.Check(err, gc.ErrorMatches, `unknown life value "revenant"`)
	c.Check(life, gc.Equals, agent.Life(""))
}
예제 #3
0
파일: facade_test.go 프로젝트: bac/juju
func (s *FacadeSuite) TestLifeErrUnauthorized(c *gc.C) {
	result := params.AgentGetEntitiesResult{
		Error: &params.Error{Code: params.CodeUnauthorized},
	}
	life, err := testLifeAPIResult(c, result)
	c.Check(err, gc.Equals, agent.ErrDenied)
	c.Check(life, gc.Equals, agent.Life(""))
}
예제 #4
0
파일: facade_test.go 프로젝트: bac/juju
func (s *FacadeSuite) TestLifeRandomError(c *gc.C) {
	result := params.AgentGetEntitiesResult{
		Error: &params.Error{Message: "squish"},
	}
	life, err := testLifeAPIResult(c, result)
	c.Check(err, gc.ErrorMatches, "squish")
	c.Check(life, gc.Equals, agent.Life(""))
}
예제 #5
0
파일: facade_test.go 프로젝트: bac/juju
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(""))
}
예제 #6
0
파일: facade_test.go 프로젝트: bac/juju
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(""))
}