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


Golang modelcmd.NewModelCommandBase函數代碼示例

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


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

示例1: TestsUnknownUserLogin

func (s *macaroonLoginSuite) TestsUnknownUserLogin(c *gc.C) {
	s.DischargerLogin = func() string {
		return "[email protected]"
	}

	cmd := modelcmd.NewModelCommandBase(s.store, s.controllerName, s.accountName, s.modelName)
	_, err := cmd.NewAPIRoot()
	c.Assert(err, gc.ErrorMatches, "connecting with cached addresses: invalid entity name or password \\(unauthorized access\\)")
}
開發者ID:AlexisBruemmer,項目名稱:juju,代碼行數:9,代碼來源:modelcommand_test.go

示例2: TestsSuccessfulLogin

func (s *macaroonLoginSuite) TestsSuccessfulLogin(c *gc.C) {
	s.DischargerLogin = func() string {
		return testUser
	}

	cmd := modelcmd.NewModelCommandBase(s.store, s.controllerName, s.accountName, s.modelName)
	_, err := cmd.NewAPIRoot()
	c.Assert(err, jc.ErrorIsNil)
}
開發者ID:AlexisBruemmer,項目名稱:juju,代碼行數:9,代碼來源:modelcommand_test.go

示例3: TestsFailToObtainDischargeLogin

func (s *macaroonLoginSuite) TestsFailToObtainDischargeLogin(c *gc.C) {
	s.DischargerLogin = func() string {
		return ""
	}

	cmd := modelcmd.NewModelCommandBase(s.store, s.controllerName, s.accountName, s.modelName)
	_, err := cmd.NewAPIRoot()
	c.Assert(err, gc.ErrorMatches, "connecting with cached addresses: cannot get discharge.*")
}
開發者ID:AlexisBruemmer,項目名稱:juju,代碼行數:9,代碼來源:modelcommand_test.go

示例4: TestsSuccessfulLogin

func (s *macaroonLoginSuite) TestsSuccessfulLogin(c *gc.C) {
	s.DischargerLogin = func() string {
		return testUser
	}

	cmd := modelcmd.NewModelCommandBase(s.envName, nil, nil)
	_, err := cmd.NewAPIRoot()
	c.Assert(err, jc.ErrorIsNil)
}
開發者ID:exekias,項目名稱:juju,代碼行數:9,代碼來源:modelcommand_test.go

示例5: TestConfigEnvDoesntExist

func (s *EnvConfigSuite) TestConfigEnvDoesntExist(c *gc.C) {
	cmd := modelcmd.NewModelCommandBase("dummy", s.client, nil)
	s.writeStore(c, false)

	_, err := cmd.Config(s.store, nil)
	c.Assert(err, jc.Satisfies, errors.IsNotFound)
	c.Check(s.client.getCalled, jc.IsFalse)
	c.Check(s.client.closeCalled, jc.IsFalse)
}
開發者ID:exekias,項目名稱:juju,代碼行數:9,代碼來源:modelcommand_test.go

示例6: TestConfigWithNoBootstrapWithClientErr

func (s *EnvConfigSuite) TestConfigWithNoBootstrapWithClientErr(c *gc.C) {
	cmd := modelcmd.NewModelCommandBase(s.envName, s.client, errors.New("problem opening connection"))
	s.writeStore(c, false)

	_, err := cmd.Config(s.store, nil)
	c.Assert(err, gc.ErrorMatches, "problem opening connection")
	c.Check(s.client.getCalled, jc.IsFalse)
	c.Check(s.client.closeCalled, jc.IsFalse)
}
開發者ID:exekias,項目名稱:juju,代碼行數:9,代碼來源:modelcommand_test.go

示例7: TestsUnknownUserLogin

func (s *macaroonLoginSuite) TestsUnknownUserLogin(c *gc.C) {
	s.DischargerLogin = func() string {
		return "[email protected]"
	}

	cmd := modelcmd.NewModelCommandBase(s.envName, nil, nil)
	_, err := cmd.NewAPIRoot()
	// TODO(rog) is this really the right error here?
	c.Assert(err, gc.ErrorMatches, `model "`+s.envName+`" not found`)
}
開發者ID:exekias,項目名稱:juju,代碼行數:10,代碼來源:modelcommand_test.go

示例8: TestConfigWithNoBootstrapWithEnvGetError

func (s *EnvConfigSuite) TestConfigWithNoBootstrapWithEnvGetError(c *gc.C) {
	cmd := modelcmd.NewModelCommandBase(s.envName, s.client, nil)
	s.writeStore(c, false)
	s.client.err = errors.New("problem getting model attributes")

	_, err := cmd.Config(s.store, nil)
	c.Assert(err, gc.ErrorMatches, "problem getting model attributes")
	c.Check(s.client.getCalled, jc.IsTrue)
	c.Check(s.client.closeCalled, jc.IsTrue)
}
開發者ID:exekias,項目名稱:juju,代碼行數:10,代碼來源:modelcommand_test.go

示例9: TestConfigWithNoBootstrapNoClient

func (s *EnvConfigSuite) TestConfigWithNoBootstrapNoClient(c *gc.C) {
	cmd := modelcmd.NewModelCommandBase(s.envName, s.client, nil)
	s.writeStore(c, false)

	cfg, err := cmd.Config(s.store, nil)
	c.Assert(err, jc.ErrorIsNil)
	c.Check(cfg.Name(), gc.Equals, s.envName)
	c.Check(s.client.getCalled, jc.IsTrue)
	c.Check(s.client.closeCalled, jc.IsTrue)
}
開發者ID:exekias,項目名稱:juju,代碼行數:10,代碼來源:modelcommand_test.go

示例10: assertUnknownModel

func (s *BaseCommandSuite) assertUnknownModel(c *gc.C, current, expectedCurrent string) {
	s.store.Models["foo"].CurrentModel = current
	apiOpen := func(*api.Info, api.DialOpts) (api.Connection, error) {
		return nil, errors.Trace(&params.Error{Code: params.CodeModelNotFound, Message: "model deaddeaf not found"})
	}
	cmd := modelcmd.NewModelCommandBase(s.store, "foo", "[email protected]/badmodel")
	cmd.SetAPIOpen(apiOpen)
	conn, err := cmd.NewAPIRoot()
	c.Assert(conn, gc.IsNil)
	msg := strings.Replace(err.Error(), "\n", "", -1)
	c.Assert(msg, gc.Equals, `model "[email protected]/badmodel" has been removed from the controller, run 'juju models' and switch to one of them.There are 1 accessible models on controller "foo".`)
	c.Assert(s.store.Models["foo"].Models, gc.HasLen, 1)
	c.Assert(s.store.Models["foo"].Models["[email protected]/goodmodel"], gc.DeepEquals, jujuclient.ModelDetails{"deadbeef2"})
	c.Assert(s.store.Models["foo"].CurrentModel, gc.Equals, expectedCurrent)
}
開發者ID:kat-co,項目名稱:juju,代碼行數:15,代碼來源:base_test.go


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