當前位置: 首頁>>代碼示例>>Golang>>正文


Golang upgrader.NewUnitUpgraderAPI函數代碼示例

本文整理匯總了Golang中github.com/juju/juju/apiserver/upgrader.NewUnitUpgraderAPI函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewUnitUpgraderAPI函數的具體用法?Golang NewUnitUpgraderAPI怎麽用?Golang NewUnitUpgraderAPI使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了NewUnitUpgraderAPI函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: TestUpgraderAPIRefusesNonUnitAgent

func (s *unitUpgraderSuite) TestUpgraderAPIRefusesNonUnitAgent(c *gc.C) {
	anAuthorizer := s.authorizer
	anAuthorizer.Tag = names.NewMachineTag("7")
	anUpgrader, err := upgrader.NewUnitUpgraderAPI(s.State, s.resources, anAuthorizer)
	c.Check(err, gc.NotNil)
	c.Check(anUpgrader, gc.IsNil)
	c.Assert(err, gc.ErrorMatches, "permission denied")
}
開發者ID:AlexisBruemmer,項目名稱:juju,代碼行數:8,代碼來源:unitupgrader_test.go

示例2: TestDesiredVersionRefusesWrongAgent

func (s *unitUpgraderSuite) TestDesiredVersionRefusesWrongAgent(c *gc.C) {
	anAuthorizer := s.authorizer
	anAuthorizer.Tag = names.NewUnitTag("wordpress/12354")
	anUpgrader, err := upgrader.NewUnitUpgraderAPI(s.State, s.resources, anAuthorizer)
	c.Check(err, jc.ErrorIsNil)
	args := params.Entities{
		Entities: []params.Entity{{Tag: s.rawUnit.Tag().String()}},
	}
	results, err := anUpgrader.DesiredVersion(args)
	// It is not an error to make the request, but the specific item is rejected
	c.Assert(err, jc.ErrorIsNil)
	c.Check(results.Results, gc.HasLen, 1)
	toolResult := results.Results[0]
	c.Assert(toolResult.Error, gc.DeepEquals, apiservertesting.ErrUnauthorized)
}
開發者ID:AlexisBruemmer,項目名稱:juju,代碼行數:15,代碼來源:unitupgrader_test.go

示例3: TestWatchAPIVersionRefusesWrongAgent

func (s *unitUpgraderSuite) TestWatchAPIVersionRefusesWrongAgent(c *gc.C) {
	// We are a unit agent, but not the one we are trying to track
	anAuthorizer := s.authorizer
	anAuthorizer.Tag = names.NewUnitTag("wordpress/12354")
	anUpgrader, err := upgrader.NewUnitUpgraderAPI(s.State, s.resources, anAuthorizer)
	c.Check(err, jc.ErrorIsNil)
	args := params.Entities{
		Entities: []params.Entity{{Tag: s.rawUnit.Tag().String()}},
	}
	results, err := anUpgrader.WatchAPIVersion(args)
	// It is not an error to make the request, but the specific item is rejected
	c.Assert(err, jc.ErrorIsNil)
	c.Check(results.Results, gc.HasLen, 1)
	c.Check(results.Results[0].NotifyWatcherId, gc.Equals, "")
	c.Assert(results.Results[0].Error, gc.DeepEquals, apiservertesting.ErrUnauthorized)
}
開發者ID:AlexisBruemmer,項目名稱:juju,代碼行數:16,代碼來源:unitupgrader_test.go

示例4: TestSetToolsRefusesWrongAgent

func (s *unitUpgraderSuite) TestSetToolsRefusesWrongAgent(c *gc.C) {
	anAuthorizer := s.authorizer
	anAuthorizer.Tag = names.NewUnitTag("wordpress/12354")
	anUpgrader, err := upgrader.NewUnitUpgraderAPI(s.State, s.resources, anAuthorizer)
	c.Check(err, gc.IsNil)
	args := params.EntitiesVersion{
		AgentTools: []params.EntityVersion{{
			Tag: s.rawUnit.Tag().String(),
			Tools: &params.Version{
				Version: version.Current,
			},
		}},
	}

	results, err := anUpgrader.SetTools(args)
	c.Assert(results.Results, gc.HasLen, 1)
	c.Assert(results.Results[0].Error, gc.DeepEquals, apiservertesting.ErrUnauthorized)
}
開發者ID:kapilt,項目名稱:juju,代碼行數:18,代碼來源:unitupgrader_test.go

示例5: SetUpTest

func (s *unitUpgraderSuite) SetUpTest(c *gc.C) {
	s.JujuConnSuite.SetUpTest(c)
	s.resources = common.NewResources()
	s.AddCleanup(func(_ *gc.C) { s.resources.StopAll() })

	// Create a machine and unit to work with
	var err error
	_, err = s.State.AddMachine("quantal", state.JobHostUnits)
	c.Assert(err, jc.ErrorIsNil)
	svc := s.AddTestingService(c, "wordpress", s.AddTestingCharm(c, "wordpress"))
	s.rawUnit, err = svc.AddUnit()
	c.Assert(err, jc.ErrorIsNil)
	// Assign the unit to the machine.
	s.rawMachine, err = s.rawUnit.AssignToCleanMachine()
	c.Assert(err, jc.ErrorIsNil)

	// The default auth is as the unit agent
	s.authorizer = apiservertesting.FakeAuthorizer{
		Tag: s.rawUnit.Tag(),
	}
	s.upgrader, err = upgrader.NewUnitUpgraderAPI(s.State, s.resources, s.authorizer)
	c.Assert(err, jc.ErrorIsNil)
}
開發者ID:AlexisBruemmer,項目名稱:juju,代碼行數:23,代碼來源:unitupgrader_test.go


注:本文中的github.com/juju/juju/apiserver/upgrader.NewUnitUpgraderAPI函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。