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


Golang testing.EnvironConfig函數代碼示例

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


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

示例1: SetUpTest

func (s *ConfigSuite) SetUpTest(c *gc.C) {
	s.BaseSuite.SetUpTest(c)

	cfg, err := testing.EnvironConfig(c).Apply(vsphere.ConfigAttrs)
	c.Assert(err, jc.ErrorIsNil)
	s.config = cfg
}
開發者ID:imoapps,項目名稱:juju,代碼行數:7,代碼來源:config_test.go

示例2: TestEnvironConfigWithoutAgentVersion

func (s *InitializeSuite) TestEnvironConfigWithoutAgentVersion(c *gc.C) {
	// admin-secret blocks Initialize.
	good := testing.EnvironConfig(c)
	attrs := good.AllAttrs()
	delete(attrs, "agent-version")
	bad, err := config.New(config.NoDefaults, attrs)
	c.Assert(err, jc.ErrorIsNil)
	owner := names.NewLocalUserTag("initialize-admin")

	_, err = state.Initialize(owner, statetesting.NewMongoInfo(), bad, statetesting.NewDialOpts(), state.Policy(nil))
	c.Assert(err, gc.ErrorMatches, "agent-version must always be set in state")

	st := statetesting.Initialize(c, owner, good, nil)
	// yay side effects
	st.Close()

	s.openState(c, st.EnvironTag())
	err = s.State.UpdateEnvironConfig(map[string]interface{}{}, []string{"agent-version"}, nil)
	c.Assert(err, gc.ErrorMatches, "agent-version must always be set in state")

	// EnvironConfig remains inviolate.
	cfg, err := s.State.EnvironConfig()
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(cfg.AllAttrs(), gc.DeepEquals, good.AllAttrs())
}
開發者ID:imoapps,項目名稱:juju,代碼行數:25,代碼來源:initialize_test.go

示例3: SetUpTest

func (s *upgradesSuite) SetUpTest(c *gc.C) {
	s.BaseSuite.SetUpTest(c)
	s.MgoSuite.SetUpTest(c)
	var err error
	s.state, err = Initialize(TestingMongoInfo(), testing.EnvironConfig(c), TestingDialOpts(), Policy(nil))
	c.Assert(err, gc.IsNil)
}
開發者ID:kapilt,項目名稱:juju,代碼行數:7,代碼來源:upgrades_test.go

示例4: TestInitialize

func (s *InitializeSuite) TestInitialize(c *gc.C) {
	cfg := testing.EnvironConfig(c)
	initial := cfg.AllAttrs()
	st, err := state.Initialize(state.TestingStateInfo(), cfg, state.TestingDialOpts(), state.Policy(nil))
	c.Assert(err, gc.IsNil)
	c.Assert(st, gc.NotNil)
	err = st.Close()
	c.Assert(err, gc.IsNil)

	s.openState(c)

	cfg, err = s.State.EnvironConfig()
	c.Assert(err, gc.IsNil)
	c.Assert(cfg.AllAttrs(), gc.DeepEquals, initial)

	env, err := s.State.Environment()
	c.Assert(err, gc.IsNil)
	entity, err := s.State.FindEntity("environment-" + env.UUID())
	c.Assert(err, gc.IsNil)
	annotator := entity.(state.Annotator)
	annotations, err := annotator.Annotations()
	c.Assert(err, gc.IsNil)
	c.Assert(annotations, gc.HasLen, 0)
	cons, err := s.State.EnvironConstraints()
	c.Assert(err, gc.IsNil)
	c.Assert(&cons, jc.Satisfies, constraints.IsEmpty)

	addrs, err := s.State.APIHostPorts()
	c.Assert(err, gc.IsNil)
	c.Assert(addrs, gc.HasLen, 0)

	info, err := s.State.StateServerInfo()
	c.Assert(err, gc.IsNil)
	c.Assert(info, jc.DeepEquals, &state.StateServerInfo{})
}
開發者ID:rogpeppe,項目名稱:juju,代碼行數:35,代碼來源:initialize_test.go

示例5: initEnv

func (s *BaseSuite) initEnv(c *gc.C) {
	cfg, err := testing.EnvironConfig(c).Apply(ConfigAttrs)
	c.Assert(err, jc.ErrorIsNil)
	env, err := environs.New(cfg)
	c.Assert(err, jc.ErrorIsNil)
	s.Env = env.(*environ)
	s.setConfig(c, cfg)
}
開發者ID:imoapps,項目名稱:juju,代碼行數:8,代碼來源:testing_test.go

示例6: SetUpTest

func (s *storeManagerStateSuite) SetUpTest(c *gc.C) {
	s.BaseSuite.SetUpTest(c)
	s.MgoSuite.SetUpTest(c)
	st, err := Initialize(TestingMongoInfo(), testing.EnvironConfig(c), TestingDialOpts(), nil)
	c.Assert(err, gc.IsNil)
	s.State = st
	s.State.AddAdminUser("pass")
}
開發者ID:kapilt,項目名稱:juju,代碼行數:8,代碼來源:megawatcher_internal_test.go

示例7: NewConfig

func (s *BaseSuiteUnpatched) NewConfig(c *gc.C, updates testing.Attrs) *config.Config {
	var err error
	cfg := testing.EnvironConfig(c)
	cfg, err = cfg.Apply(ConfigAttrs)
	c.Assert(err, jc.ErrorIsNil)
	cfg, err = cfg.Apply(updates)
	c.Assert(err, jc.ErrorIsNil)
	return cfg
}
開發者ID:Pankov404,項目名稱:juju,代碼行數:9,代碼來源:testing_test.go

示例8: SetUpTest

func (s *storeManagerStateSuite) SetUpTest(c *gc.C) {
	s.BaseSuite.SetUpTest(c)
	s.MgoSuite.SetUpTest(c)
	st, err := Initialize(TestingMongoInfo(), testing.EnvironConfig(c), TestingDialOpts(), nil)
	c.Assert(err, gc.IsNil)
	s.State = st
	env, err := st.Environment()
	c.Assert(err, gc.IsNil)
	s.owner = env.Owner()
}
開發者ID:zhouqt,項目名稱:juju,代碼行數:10,代碼來源:megawatcher_internal_test.go

示例9: SetUpTest

func (s *compatSuite) SetUpTest(c *gc.C) {
	s.BaseSuite.SetUpTest(c)
	s.MgoSuite.SetUpTest(c)
	st, err := Initialize(TestingMongoInfo(), testing.EnvironConfig(c), TestingDialOpts(), nil)
	c.Assert(err, gc.IsNil)
	s.state = st
	env, err := s.state.Environment()
	c.Assert(err, gc.IsNil)
	s.env = env
}
開發者ID:zhouqt,項目名稱:juju,代碼行數:10,代碼來源:compat_test.go

示例10: Initialize

// Initialize initializes the state and returns it. If state was not
// already initialized, and cfg is nil, the minimal default environment
// configuration will be used.
func Initialize(c *gc.C, owner names.UserTag, cfg *config.Config, policy state.Policy) *state.State {
	if cfg == nil {
		cfg = testing.EnvironConfig(c)
	}
	mgoInfo := NewMongoInfo()
	dialOpts := NewDialOpts()

	st, err := state.Initialize(owner, mgoInfo, cfg, dialOpts, policy)
	c.Assert(err, jc.ErrorIsNil)
	return st
}
開發者ID:imoapps,項目名稱:juju,代碼行數:14,代碼來源:conn.go

示例11: SetUpTest

func (s *SettingsSuite) SetUpTest(c *gc.C) {
	s.MgoSuite.SetUpTest(c)
	s.BaseSuite.SetUpTest(c)
	// TODO(dfc) this logic is duplicated with the metawatcher_test.
	cfg := testing.EnvironConfig(c)
	state, err := Initialize(TestingMongoInfo(), cfg, TestingDialOpts(), Policy(nil))
	c.Assert(err, gc.IsNil)
	s.AddCleanup(func(*gc.C) { state.Close() })
	s.state = state
	s.key = "config"
}
開發者ID:kapilt,項目名稱:juju,代碼行數:11,代碼來源:settings_test.go

示例12: newConfig

func (ts configTestSpec) newConfig(c *gc.C) *config.Config {
	filename := ts.writeAuthFile(c)

	attrs := ts.attrs()
	if filename != "" {
		attrs["auth-file"] = filename
	}
	cfg, err := testing.EnvironConfig(c).Apply(attrs)
	c.Assert(err, jc.ErrorIsNil)
	return cfg
}
開發者ID:imoapps,項目名稱:juju,代碼行數:11,代碼來源:config_test.go

示例13: TestInitialize

func (s *InitializeSuite) TestInitialize(c *gc.C) {
	cfg := testing.EnvironConfig(c)
	uuid, _ := cfg.UUID()
	initial := cfg.AllAttrs()
	st, err := state.Initialize(state.TestingMongoInfo(), cfg, state.TestingDialOpts(), nil)
	c.Assert(err, gc.IsNil)
	c.Assert(st, gc.NotNil)
	envTag := st.EnvironTag()
	c.Assert(envTag.Id(), gc.Equals, uuid)
	err = st.Close()
	c.Assert(err, gc.IsNil)

	s.openState(c)

	cfg, err = s.State.EnvironConfig()
	c.Assert(err, gc.IsNil)
	c.Assert(cfg.AllAttrs(), gc.DeepEquals, initial)
	// Check that the environment has been created.
	env, err := s.State.Environment()
	c.Assert(err, gc.IsNil)
	c.Assert(env.Tag(), gc.Equals, envTag)
	// Check that the owner has been created.
	owner := names.NewLocalUserTag("admin")
	c.Assert(env.Owner(), gc.Equals, owner)
	// Check that the owner can be retrieved by the tag.
	entity, err := s.State.FindEntity(env.Owner())
	c.Assert(err, gc.IsNil)
	c.Assert(entity.Tag(), gc.Equals, owner)
	// Check that the owner has an EnvUser created for the bootstrapped environment.
	envUser, err := s.State.EnvironmentUser(env.Owner())
	c.Assert(err, gc.IsNil)
	c.Assert(envUser.UserTag().Username(), gc.Equals, env.Owner().Username())
	c.Assert(envUser.EnvironmentTag(), gc.Equals, env.Tag())

	// Check that the environment can be found through the tag.
	entity, err = s.State.FindEntity(envTag)
	c.Assert(err, gc.IsNil)
	annotator := entity.(state.Annotator)
	annotations, err := annotator.Annotations()
	c.Assert(err, gc.IsNil)
	c.Assert(annotations, gc.HasLen, 0)
	cons, err := s.State.EnvironConstraints()
	c.Assert(err, gc.IsNil)
	c.Assert(&cons, jc.Satisfies, constraints.IsEmpty)

	addrs, err := s.State.APIHostPorts()
	c.Assert(err, gc.IsNil)
	c.Assert(addrs, gc.HasLen, 0)

	info, err := s.State.StateServerInfo()
	c.Assert(err, gc.IsNil)
	c.Assert(info, jc.DeepEquals, &state.StateServerInfo{EnvironmentTag: envTag})
}
開發者ID:zhouqt,項目名稱:juju,代碼行數:53,代碼來源:initialize_test.go

示例14: TestEnvironConfigSuccess

func (s *AddresserSuite) TestEnvironConfigSuccess(c *gc.C) {
	config := coretesting.EnvironConfig(c)
	s.st.setConfig(c, config)

	result, err := s.api.EnvironConfig()
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(result, jc.DeepEquals, params.EnvironConfigResult{
		Config: config.AllAttrs(),
	})

	s.st.stub.CheckCallNames(c, "EnvironConfig")
}
開發者ID:claudiu-coblis,項目名稱:juju,代碼行數:12,代碼來源:addresser_test.go

示例15: TestEnvironConfigSuccess

func (s *InstancePollerSuite) TestEnvironConfigSuccess(c *gc.C) {
	envConfig := coretesting.EnvironConfig(c)
	s.st.SetConfig(c, envConfig)

	result, err := s.api.EnvironConfig()
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(result, jc.DeepEquals, params.EnvironConfigResult{
		Config: envConfig.AllAttrs(),
	})

	s.st.CheckCallNames(c, "EnvironConfig")
}
開發者ID:imoapps,項目名稱:juju,代碼行數:12,代碼來源:instancepoller_test.go


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