当前位置: 首页>>代码示例>>Golang>>正文


Golang service.PatchFacadeCall函数代码示例

本文整理汇总了Golang中github.com/juju/juju/api/service.PatchFacadeCall函数的典型用法代码示例。如果您正苦于以下问题:Golang PatchFacadeCall函数的具体用法?Golang PatchFacadeCall怎么用?Golang PatchFacadeCall使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了PatchFacadeCall函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: TestServiceSetCharm

func (s *serviceSuite) TestServiceSetCharm(c *gc.C) {
	var called bool
	service.PatchFacadeCall(s, s.client, func(request string, a, response interface{}) error {
		called = true
		c.Assert(request, gc.Equals, "SetCharm")
		args, ok := a.(params.ServiceSetCharm)
		c.Assert(ok, jc.IsTrue)
		c.Assert(args.ServiceName, gc.Equals, "service")
		c.Assert(args.CharmUrl, gc.Equals, "cs:trusty/service-1")
		c.Assert(args.ForceSeries, gc.Equals, true)
		c.Assert(args.ForceUnits, gc.Equals, true)
		return nil
	})
	cfg := service.SetCharmConfig{
		ServiceName: "service",
		CharmID: charmstore.CharmID{
			URL: charm.MustParseURL("trusty/service-1"),
		},
		ForceSeries: true,
		ForceUnits:  true,
	}
	err := s.client.SetCharm(cfg)
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(called, jc.IsTrue)
}
开发者ID:makyo,项目名称:juju,代码行数:25,代码来源:client_test.go

示例2: TestSetServiceDeploy

func (s *serviceSuite) TestSetServiceDeploy(c *gc.C) {
	var called bool
	service.PatchFacadeCall(s, s.client, func(request string, a, response interface{}) error {
		called = true
		c.Assert(request, gc.Equals, "ServicesDeploy")
		args, ok := a.(params.ServicesDeploy)
		c.Assert(ok, jc.IsTrue)
		c.Assert(args.Services, gc.HasLen, 1)
		c.Assert(args.Services[0].CharmUrl, gc.Equals, "charmURL")
		c.Assert(args.Services[0].ServiceName, gc.Equals, "serviceA")
		c.Assert(args.Services[0].Series, gc.Equals, "series")
		c.Assert(args.Services[0].NumUnits, gc.Equals, 2)
		c.Assert(args.Services[0].ConfigYAML, gc.Equals, "configYAML")
		c.Assert(args.Services[0].Constraints, gc.DeepEquals, constraints.MustParse("mem=4G"))
		c.Assert(args.Services[0].ToMachineSpec, gc.Equals, "machineSpec")
		c.Assert(args.Services[0].Networks, gc.DeepEquals, []string{"neta"})
		c.Assert(args.Services[0].Storage, gc.DeepEquals, map[string]storage.Constraints{"data": storage.Constraints{Pool: "pool"}})

		result := response.(*params.ErrorResults)
		result.Results = make([]params.ErrorResult, 1)
		return nil
	})
	err := s.client.ServiceDeploy("charmURL", "serviceA", "series", 2, "configYAML", constraints.MustParse("mem=4G"),
		"machineSpec", nil, []string{"neta"}, map[string]storage.Constraints{"data": storage.Constraints{Pool: "pool"}})
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(called, jc.IsTrue)
}
开发者ID:imoapps,项目名称:juju,代码行数:27,代码来源:client_test.go

示例3: TestSetServiceMetricCredentialsFails

func (s *serviceSuite) TestSetServiceMetricCredentialsFails(c *gc.C) {
	var called bool
	service.PatchFacadeCall(s, s.client, func(request string, args, response interface{}) error {
		called = true
		c.Assert(request, gc.Equals, "SetMetricCredentials")
		result := response.(*params.ErrorResults)
		result.Results = make([]params.ErrorResult, 1)
		result.Results[0].Error = common.ServerError(common.ErrPerm)
		return result.OneError()
	})
	err := s.client.SetMetricCredentials("service", []byte("creds"))
	c.Assert(err, gc.ErrorMatches, "permission denied")
	c.Assert(called, jc.IsTrue)
}
开发者ID:makyo,项目名称:juju,代码行数:14,代码来源:client_test.go

示例4: TestServiceSetCharm

func (s *serviceSuite) TestServiceSetCharm(c *gc.C) {
	var called bool
	service.PatchFacadeCall(s, s.client, func(request string, a, response interface{}) error {
		called = true
		c.Assert(request, gc.Equals, "ServiceSetCharm")
		args, ok := a.(params.ServiceSetCharm)
		c.Assert(ok, jc.IsTrue)
		c.Assert(args.ServiceName, gc.Equals, "service")
		c.Assert(args.CharmUrl, gc.Equals, "charmURL")
		c.Assert(args.ForceSeries, gc.Equals, true)
		c.Assert(args.ForceUnits, gc.Equals, true)
		return nil
	})
	err := s.client.ServiceSetCharm("service", "charmURL", true, true)
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(called, jc.IsTrue)
}
开发者ID:imoapps,项目名称:juju,代码行数:17,代码来源:client_test.go

示例5: TestServiceGetCharmURL

func (s *serviceSuite) TestServiceGetCharmURL(c *gc.C) {
	var called bool
	service.PatchFacadeCall(s, s.client, func(request string, a, response interface{}) error {
		called = true
		c.Assert(request, gc.Equals, "GetCharmURL")
		args, ok := a.(params.ServiceGet)
		c.Assert(ok, jc.IsTrue)
		c.Assert(args.ServiceName, gc.Equals, "service")

		result := response.(*params.StringResult)
		result.Result = "curl"
		return nil
	})
	curl, err := s.client.GetCharmURL("service")
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(curl, gc.DeepEquals, charm.MustParseURL("curl"))
	c.Assert(called, jc.IsTrue)
}
开发者ID:makyo,项目名称:juju,代码行数:18,代码来源:client_test.go

示例6: TestSetServiceMetricCredentials

func (s *serviceSuite) TestSetServiceMetricCredentials(c *gc.C) {
	var called bool
	service.PatchFacadeCall(s, s.client, func(request string, a, response interface{}) error {
		called = true
		c.Assert(request, gc.Equals, "SetMetricCredentials")
		args, ok := a.(params.ServiceMetricCredentials)
		c.Assert(ok, jc.IsTrue)
		c.Assert(args.Creds, gc.HasLen, 1)
		c.Assert(args.Creds[0].ServiceName, gc.Equals, "serviceA")
		c.Assert(args.Creds[0].MetricCredentials, gc.DeepEquals, []byte("creds 1"))

		result := response.(*params.ErrorResults)
		result.Results = make([]params.ErrorResult, 1)
		return nil
	})
	err := s.client.SetMetricCredentials("serviceA", []byte("creds 1"))
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(called, jc.IsTrue)
}
开发者ID:makyo,项目名称:juju,代码行数:19,代码来源:client_test.go

示例7: TestSetServiceDeploy

func (s *serviceSuite) TestSetServiceDeploy(c *gc.C) {
	var called bool
	service.PatchFacadeCall(s, s.client, func(request string, a, response interface{}) error {
		called = true
		c.Assert(request, gc.Equals, "Deploy")
		args, ok := a.(params.ServicesDeploy)
		c.Assert(ok, jc.IsTrue)
		c.Assert(args.Services, gc.HasLen, 1)
		c.Assert(args.Services[0].CharmUrl, gc.Equals, "cs:trusty/a-charm-1")
		c.Assert(args.Services[0].ServiceName, gc.Equals, "serviceA")
		c.Assert(args.Services[0].Series, gc.Equals, "series")
		c.Assert(args.Services[0].NumUnits, gc.Equals, 2)
		c.Assert(args.Services[0].ConfigYAML, gc.Equals, "configYAML")
		c.Assert(args.Services[0].Constraints, gc.DeepEquals, constraints.MustParse("mem=4G"))
		c.Assert(args.Services[0].Placement, gc.DeepEquals, []*instance.Placement{{"scope", "directive"}})
		c.Assert(args.Services[0].EndpointBindings, gc.DeepEquals, map[string]string{"foo": "bar"})
		c.Assert(args.Services[0].Storage, gc.DeepEquals, map[string]storage.Constraints{"data": storage.Constraints{Pool: "pool"}})
		c.Assert(args.Services[0].Resources, gc.DeepEquals, map[string]string{"foo": "bar"})

		result := response.(*params.ErrorResults)
		result.Results = make([]params.ErrorResult, 1)
		return nil
	})

	args := service.DeployArgs{
		CharmID: charmstore.CharmID{
			URL: charm.MustParseURL("trusty/a-charm-1"),
		},
		ServiceName:      "serviceA",
		Series:           "series",
		NumUnits:         2,
		ConfigYAML:       "configYAML",
		Cons:             constraints.MustParse("mem=4G"),
		Placement:        []*instance.Placement{{"scope", "directive"}},
		Networks:         []string{"neta"},
		Storage:          map[string]storage.Constraints{"data": storage.Constraints{Pool: "pool"}},
		Resources:        map[string]string{"foo": "bar"},
		EndpointBindings: map[string]string{"foo": "bar"},
	}
	err := s.client.Deploy(args)
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(called, jc.IsTrue)
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:43,代码来源:client_test.go


注:本文中的github.com/juju/juju/api/service.PatchFacadeCall函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。