當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。