func (s *facadeSuite) TestReportKeys(c *gc.C) { stub := new(testing.Stub) apiCaller := basetesting.APICallerFunc(func( objType string, version int, id, request string, args, response interface{}, ) error { c.Check(objType, gc.Equals, "HostKeyReporter") c.Check(version, gc.Equals, 0) c.Check(id, gc.Equals, "") stub.AddCall(request, args) *response.(*params.ErrorResults) = params.ErrorResults{ Results: []params.ErrorResult{{ (*params.Error)(nil), }}, } return nil }) facade := hostkeyreporter.NewFacade(apiCaller) err := facade.ReportKeys("42", []string{"rsa", "dsa"}) c.Assert(err, jc.ErrorIsNil) stub.CheckCalls(c, []testing.StubCall{{ "ReportKeys", []interface{}{params.SSHHostKeySet{ EntityKeys: []params.SSHHostKeys{{ Tag: names.NewMachineTag("42").String(), PublicKeys: []string{"rsa", "dsa"}, }}, }}, }}) }
func (s *facadeSuite) TestCallError(c *gc.C) { apiCaller := basetesting.APICallerFunc(func( objType string, version int, id, request string, args, response interface{}, ) error { return errors.New("blam") }) facade := hostkeyreporter.NewFacade(apiCaller) err := facade.ReportKeys("42", []string{"rsa", "dsa"}) c.Assert(err, gc.ErrorMatches, "blam") }
func (s *facadeSuite) TestInnerError(c *gc.C) { apiCaller := basetesting.APICallerFunc(func( objType string, version int, id, request string, args, response interface{}, ) error { *response.(*params.ErrorResults) = params.ErrorResults{ Results: []params.ErrorResult{{ ¶ms.Error{Message: "blam"}, }}, } return nil }) facade := hostkeyreporter.NewFacade(apiCaller) err := facade.ReportKeys("42", []string{"rsa", "dsa"}) c.Assert(err, gc.ErrorMatches, "blam") }
func NewFacade(apiCaller base.APICaller) (Facade, error) { return apihostkeyreporter.NewFacade(apiCaller), nil }