本文整理汇总了Golang中github.com/juju/juju/testing.WriteEnvironments函数的典型用法代码示例。如果您正苦于以下问题:Golang WriteEnvironments函数的具体用法?Golang WriteEnvironments怎么用?Golang WriteEnvironments使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了WriteEnvironments函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestCurrentControllerHasPrecedence
func (s *SwitchSimpleSuite) TestCurrentControllerHasPrecedence(c *gc.C) {
testing.WriteEnvironments(c, testing.MultipleEnvConfig)
envcmd.WriteCurrentController("fubar")
context, err := testing.RunCommand(c, newSwitchCommand())
c.Assert(err, jc.ErrorIsNil)
c.Assert(testing.Stdout(context), gc.Equals, "fubar (controller)\n")
}
示例2: TestWithBootstrapConfigTakesPrecedence
func (s *NewAPIClientSuite) TestWithBootstrapConfigTakesPrecedence(c *gc.C) {
s.PatchValue(&version.Current, coretesting.FakeVersionNumber)
// We want to make sure that the code is using the bootstrap
// config rather than information from environments.yaml,
// even when there is an entry in environments.yaml
// We can do that by changing the info bootstrap config
// so it has a different environment name.
coretesting.WriteEnvironments(c, coretesting.MultipleEnvConfig)
store := configstore.NewMem()
s.bootstrapEnv(c, coretesting.SampleModelName, store)
info, err := store.ReadInfo(coretesting.SampleModelName)
c.Assert(err, jc.ErrorIsNil)
envName2 := coretesting.SampleCertName + "-2"
info2 := store.CreateInfo(envName2)
info2.SetBootstrapConfig(info.BootstrapConfig())
err = info2.Write()
c.Assert(err, jc.ErrorIsNil)
// Now we have info for envName2 which will actually
// cause a connection to the originally bootstrapped
// state.
apiOpen := func(*api.Info, api.DialOpts) (api.Connection, error) {
return mockedAPIState(noFlags), nil
}
st, err := juju.NewAPIFromStore(envName2, store, apiOpen)
c.Check(err, jc.ErrorIsNil)
st.Close()
}
示例3: TestConfigForNameDefault
func (*OpenSuite) TestConfigForNameDefault(c *gc.C) {
testing.WriteEnvironments(c, testing.SingleEnvConfig)
cfg, source, err := environs.ConfigForName("", configstore.NewMem())
c.Assert(err, gc.IsNil)
c.Assert(cfg.Name(), gc.Equals, "erewhemos")
c.Assert(source, gc.Equals, environs.ConfigFromEnvirons)
}
示例4: SetUpTest
func (s *ValidateImageMetadataSuite) SetUpTest(c *gc.C) {
s.FakeJujuHomeSuite.SetUpTest(c)
s.metadataDir = c.MkDir()
coretesting.WriteEnvironments(c, metadataTestEnvConfig)
s.PatchEnvironment("AWS_ACCESS_KEY_ID", "access")
s.PatchEnvironment("AWS_SECRET_ACCESS_KEY", "secret")
}
示例5: TestShowsJujuEnv
func (*SwitchSimpleSuite) TestShowsJujuEnv(c *gc.C) {
testing.WriteEnvironments(c, testing.MultipleEnvConfig)
os.Setenv("JUJU_ENV", "using-env")
context, err := testing.RunCommand(c, newSwitchCommand())
c.Assert(err, jc.ErrorIsNil)
c.Assert(testing.Stdout(context), gc.Equals, "using-env\n")
}
示例6: TestSettingWritesFile
func (*SwitchSimpleSuite) TestSettingWritesFile(c *gc.C) {
testing.WriteEnvironments(c, testing.MultipleEnvConfig)
context, err := testing.RunCommand(c, &SwitchCommand{}, "erewhemos-2")
c.Assert(err, jc.ErrorIsNil)
c.Assert(testing.Stdout(context), gc.Equals, "erewhemos -> erewhemos-2\n")
c.Assert(envcmd.ReadCurrentEnvironment(), gc.Equals, "erewhemos-2")
}
示例7: TestCurrentEnvironmentHasPrecidence
func (s *SwitchSimpleSuite) TestCurrentEnvironmentHasPrecidence(c *gc.C) {
testing.WriteEnvironments(c, testing.MultipleEnvConfig)
s.FakeHomeSuite.Home.AddFiles(c, gitjujutesting.TestFile{".juju/current-environment", "fubar"})
context, err := testing.RunCommand(c, &SwitchCommand{})
c.Assert(err, jc.ErrorIsNil)
c.Assert(testing.Stdout(context), gc.Equals, "fubar\n")
}
示例8: TestListEnvironmentsOSJujuEnvSet
func (*SwitchSimpleSuite) TestListEnvironmentsOSJujuEnvSet(c *gc.C) {
testing.WriteEnvironments(c, testing.MultipleEnvConfig)
os.Setenv("JUJU_ENV", "using-env")
context, err := testing.RunCommand(c, newSwitchCommand(), "--list")
c.Assert(err, jc.ErrorIsNil)
c.Assert(testing.Stdout(context), gc.Equals, expectedEnvironments)
}
示例9: SetUpTest
func (s *ImageMetadataSuite) SetUpTest(c *gc.C) {
s.FakeJujuHomeSuite.SetUpTest(c)
s.dir = c.MkDir()
// Create a fake certificate so azure test environment can be opened.
testing.WriteEnvironments(c, metadataTestEnvConfig)
s.PatchEnvironment("AWS_ACCESS_KEY_ID", "access")
s.PatchEnvironment("AWS_SECRET_ACCESS_KEY", "secret")
}
示例10: TestJujuEnvOverCurrentEnvironment
func (s *SwitchSimpleSuite) TestJujuEnvOverCurrentEnvironment(c *gc.C) {
testing.WriteEnvironments(c, testing.MultipleEnvConfig)
s.FakeHomeSuite.Home.AddFiles(c, gitjujutesting.TestFile{".juju/current-environment", "fubar"})
os.Setenv("JUJU_ENV", "using-env")
context, err := testing.RunCommand(c, newSwitchCommand())
c.Assert(err, jc.ErrorIsNil)
c.Assert(testing.Stdout(context), gc.Equals, "using-env\n")
}
示例11: TestSettingWritesFile
func (*SwitchSimpleSuite) TestSettingWritesFile(c *gc.C) {
testing.WriteEnvironments(c, testing.MultipleEnvConfig)
context, err := testing.RunCommand(c, newSwitchCommand(), "erewhemos-2")
c.Assert(err, jc.ErrorIsNil)
c.Assert(testing.Stderr(context), gc.Equals, "-> erewhemos-2\n")
currentEnv, err := modelcmd.ReadCurrentModel()
c.Assert(err, jc.ErrorIsNil)
c.Assert(currentEnv, gc.Equals, "erewhemos-2")
}
示例12: SetUpTest
func (s *datasourceSuite) SetUpTest(c *gc.C) {
s.FakeJujuHomeSuite.SetUpTest(c)
testing.WriteEnvironments(c, existingEnv)
environ, err := environs.PrepareFromName("test", testing.Context(c), configstore.NewMem())
c.Assert(err, gc.IsNil)
s.stor = environ.Storage()
s.baseURL, err = s.stor.URL("")
c.Assert(err, gc.IsNil)
}
示例13: TestNameNotDefault
func (s *NewAPIClientSuite) TestNameNotDefault(c *gc.C) {
envName := coretesting.SampleCertName + "-2"
coretesting.WriteEnvironments(c, coretesting.MultipleEnvConfig, envName)
s.bootstrapEnv(c, envName, defaultConfigStore(c))
apiclient, err := juju.NewAPIClientFromName(envName)
c.Assert(err, jc.ErrorIsNil)
defer apiclient.Close()
assertEnvironmentName(c, apiclient, envName)
}
示例14: TestEnvironCommandInit
func (s *EnvironmentCommandSuite) TestEnvironCommandInit(c *gc.C) {
// Take environment name from command line arg.
testEnsureEnvName(c, "explicit", "-e", "explicit")
// Take environment name from the default.
coretesting.WriteEnvironments(c, coretesting.MultipleEnvConfig)
testEnsureEnvName(c, coretesting.SampleEnvName)
// Take environment name from the one and only environment,
// even if it is not explicitly marked as default.
coretesting.WriteEnvironments(c, coretesting.SingleEnvConfigNoDefault)
testEnsureEnvName(c, coretesting.SampleEnvName)
// If there is a current-environment file, use that.
err := envcmd.WriteCurrentEnvironment("fubar")
c.Assert(err, gc.IsNil)
testEnsureEnvName(c, "fubar")
}
示例15: TestNewConnFromNameNotDefault
func (s *NewConnSuite) TestNewConnFromNameNotDefault(c *gc.C) {
coretesting.WriteEnvironments(c, coretesting.MultipleEnvConfig)
// The default environment is "erewhemos", so make sure we get what we ask for.
const envName = "erewhemos-2"
bootstrapEnv(c, envName, defaultConfigStore(c))
conn, err := juju.NewConnFromName(envName)
c.Assert(err, gc.IsNil)
defer assertClose(c, conn)
c.Assert(conn.Environ.Name(), gc.Equals, envName)
}