本文整理汇总了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
}
示例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())
}
示例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)
}
示例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{})
}
示例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)
}
示例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")
}
示例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
}
示例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()
}
示例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
}
示例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
}
示例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"
}
示例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
}
示例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})
}
示例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")
}
示例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")
}