当前位置: 首页>>代码示例>>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;未经允许,请勿转载。