本文整理汇总了Golang中github.com/wallyworld/core/testing.MakeFakeHome函数的典型用法代码示例。如果您正苦于以下问题:Golang MakeFakeHome函数的具体用法?Golang MakeFakeHome怎么用?Golang MakeFakeHome使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MakeFakeHome函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestConfigForNameDefault
func (*OpenSuite) TestConfigForNameDefault(c *gc.C) {
defer testing.MakeFakeHome(c, testing.SingleEnvConfig, testing.SampleCertName).Restore()
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)
}
示例2: TestListEnvironmentsOSJujuEnvSet
func (*SwitchSimpleSuite) TestListEnvironmentsOSJujuEnvSet(c *gc.C) {
defer testing.MakeFakeHome(c, testing.MultipleEnvConfig).Restore()
os.Setenv("JUJU_ENV", "using-env")
context, err := testing.RunCommand(c, &SwitchCommand{}, []string{"--list"})
c.Assert(err, gc.IsNil)
c.Assert(testing.Stdout(context), gc.Equals, expectedEnvironments)
}
示例3: TestConfigForNameNoDefault
func (*OpenSuite) TestConfigForNameNoDefault(c *gc.C) {
defer testing.MakeFakeHome(c, testing.MultipleEnvConfigNoDefault, testing.SampleCertName).Restore()
cfg, source, err := environs.ConfigForName("", configstore.NewMem())
c.Assert(err, gc.ErrorMatches, "no default environment found")
c.Assert(cfg, gc.IsNil)
c.Assert(source, gc.Equals, environs.ConfigFromEnvirons)
}
示例4: SetUpTest
func (s *ValidateToolsMetadataSuite) SetUpTest(c *gc.C) {
s.LoggingSuite.SetUpTest(c)
s.home = coretesting.MakeFakeHome(c, metadataTestEnvConfig)
s.metadataDir = c.MkDir()
s.PatchEnvironment("AWS_ACCESS_KEY_ID", "access")
s.PatchEnvironment("AWS_SECRET_ACCESS_KEY", "secret")
}
示例5: TestSettingWritesFile
func (*SwitchSimpleSuite) TestSettingWritesFile(c *gc.C) {
defer testing.MakeFakeHome(c, testing.MultipleEnvConfig).Restore()
context, err := testing.RunCommand(c, &SwitchCommand{}, []string{"erewhemos-2"})
c.Assert(err, gc.IsNil)
c.Assert(testing.Stdout(context), gc.Equals, "erewhemos -> erewhemos-2\n")
c.Assert(envcmd.ReadCurrentEnvironment(), gc.Equals, "erewhemos-2")
}
示例6: TestShowsJujuEnv
func (*SwitchSimpleSuite) TestShowsJujuEnv(c *gc.C) {
defer testing.MakeFakeHome(c, testing.MultipleEnvConfig).Restore()
os.Setenv("JUJU_ENV", "using-env")
context, err := testing.RunCommand(c, &SwitchCommand{}, nil)
c.Assert(err, gc.IsNil)
c.Assert(testing.Stdout(context), gc.Equals, "using-env\n")
}
示例7: TestCurrentEnvironmentHasPrecidence
func (*SwitchSimpleSuite) TestCurrentEnvironmentHasPrecidence(c *gc.C) {
home := testing.MakeFakeHome(c, testing.MultipleEnvConfig)
defer home.Restore()
home.AddFiles(c, []testing.TestFile{{".juju/current-environment", "fubar"}})
context, err := testing.RunCommand(c, &SwitchCommand{}, nil)
c.Assert(err, gc.IsNil)
c.Assert(testing.Stdout(context), gc.Equals, "fubar\n")
}
示例8: SetUpTest
func (s *datasourceSuite) SetUpTest(c *gc.C) {
s.home = testing.MakeFakeHome(c, existingEnv, "existing")
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)
}
示例9: TestNewFromNameWithInvalidEnvironConfig
func (*OpenSuite) TestNewFromNameWithInvalidEnvironConfig(c *gc.C) {
defer testing.MakeFakeHome(c, testing.MultipleEnvConfigNoDefault, testing.SampleCertName).Restore()
store := configstore.NewMem()
e, err := environs.NewFromName("erewhemos", store)
c.Assert(err, gc.Equals, environs.ErrNotBootstrapped)
c.Assert(e, gc.IsNil)
}
示例10: TestPrepareFromName
func (*OpenSuite) TestPrepareFromName(c *gc.C) {
defer testing.MakeFakeHome(c, testing.MultipleEnvConfigNoDefault, testing.SampleCertName).Restore()
ctx := testing.Context(c)
e, err := environs.PrepareFromName("erewhemos", ctx, configstore.NewMem())
c.Assert(err, gc.IsNil)
c.Assert(e.Name(), gc.Equals, "erewhemos")
// Check we can access storage ok, which implies the environment has been prepared.
c.Assert(e.Storage(), gc.NotNil)
}
示例11: TestJujuEnvOverCurrentEnvironment
func (*SwitchSimpleSuite) TestJujuEnvOverCurrentEnvironment(c *gc.C) {
home := testing.MakeFakeHome(c, testing.MultipleEnvConfig)
defer home.Restore()
home.AddFiles(c, []testing.TestFile{{".juju/current-environment", "fubar"}})
os.Setenv("JUJU_ENV", "using-env")
context, err := testing.RunCommand(c, &SwitchCommand{}, nil)
c.Assert(err, gc.IsNil)
c.Assert(testing.Stdout(context), gc.Equals, "using-env\n")
}
示例12: TestEnsureEnvNameErrors
func (s *EnvironmentCommandSuite) TestEnsureEnvNameErrors(c *gc.C) {
err := initEnvCommandBase(c, "").EnsureEnvName()
c.Assert(err, jc.Satisfies, environs.IsNoEnv)
// If there are multiple environments but no default,
// an error should be returned.
defer coretesting.MakeFakeHome(c, coretesting.MultipleEnvConfigNoDefault).Restore()
err = initEnvCommandBase(c, "").EnsureEnvName()
c.Assert(err, gc.Equals, envcmd.ErrNoEnvironmentSpecified)
}
示例13: makeEmptyFakeHome
// makeEmptyFakeHome creates a faked home without envtools.
func makeEmptyFakeHome(c *gc.C) (environs.Environ, *coretesting.FakeHome) {
fake := coretesting.MakeFakeHome(c, envConfig)
dummy.Reset()
store, err := configstore.Default()
c.Assert(err, gc.IsNil)
env, err := environs.PrepareFromName("peckham", nullContext(c), store)
c.Assert(err, gc.IsNil)
envtesting.RemoveAllTools(c, env)
return env, fake
}
示例14: TestEnsureEnvName
func (s *EnvironmentCommandSuite) TestEnsureEnvName(c *gc.C) {
// Take environment name from command line arg.
cmd := initEnvCommandBase(c, "explicit")
err := cmd.EnsureEnvName()
c.Assert(err, gc.IsNil)
c.Assert(cmd.EnvName, gc.Equals, "explicit")
// Take environment name from the default.
defer coretesting.MakeFakeHome(c, coretesting.MultipleEnvConfig).Restore()
testEnsureEnvName(c, coretesting.SampleEnvName)
// Take environment name from the one and only environment,
// even if it is not explicitly marked as default.
defer coretesting.MakeFakeHome(c, coretesting.SingleEnvConfigNoDefault).Restore()
testEnsureEnvName(c, coretesting.SampleEnvName)
// If there is a current-environment file, use that.
err = envcmd.WriteCurrentEnvironment("fubar")
testEnsureEnvName(c, "fubar")
}
示例15: TestNewFromName
func (*OpenSuite) TestNewFromName(c *gc.C) {
defer testing.MakeFakeHome(c, testing.MultipleEnvConfigNoDefault, testing.SampleCertName).Restore()
store := configstore.NewMem()
ctx := testing.Context(c)
e, err := environs.PrepareFromName("erewhemos", ctx, store)
c.Assert(err, gc.IsNil)
e, err = environs.NewFromName("erewhemos", store)
c.Assert(err, gc.IsNil)
c.Assert(e.Name(), gc.Equals, "erewhemos")
}