本文整理汇总了Golang中github.com/wallyworld/core/testing.MakeFakeHome函数的典型用法代码示例。如果您正苦于以下问题:Golang MakeFakeHome函数的具体用法?Golang MakeFakeHome怎么用?Golang MakeFakeHome使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MakeFakeHome函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
}
开发者ID:jameinel,项目名称:core,代码行数:7,代码来源:open_test.go
示例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)
}
开发者ID:jameinel,项目名称:core,代码行数:7,代码来源:switch_test.go
示例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)
}
开发者ID:jameinel,项目名称:core,代码行数:7,代码来源:open_test.go
示例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")
}
开发者ID:jameinel,项目名称:core,代码行数:7,代码来源:validatetoolsmetadata_test.go
示例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")
}
开发者ID:jameinel,项目名称:core,代码行数:7,代码来源:switch_test.go
示例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")
}
开发者ID:jameinel,项目名称:core,代码行数:7,代码来源:switch_test.go
示例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")
}
开发者ID:jameinel,项目名称:core,代码行数:8,代码来源:switch_test.go
示例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)
}
开发者ID:jameinel,项目名称:core,代码行数:8,代码来源:storage_test.go
示例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)
}
开发者ID:jameinel,项目名称:core,代码行数:8,代码来源:open_test.go
示例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)
}
开发者ID:jameinel,项目名称:core,代码行数:9,代码来源:open_test.go
示例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")
}
开发者ID:jameinel,项目名称:core,代码行数:9,代码来源:switch_test.go
示例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)
}
开发者ID:jameinel,项目名称:core,代码行数:10,代码来源:environmentcommand_test.go
示例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
}
开发者ID:jameinel,项目名称:core,代码行数:11,代码来源:bootstrap_test.go
示例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")
}
开发者ID:jameinel,项目名称:core,代码行数:20,代码来源:environmentcommand_test.go
示例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")
}
开发者ID:jameinel,项目名称:core,代码行数:11,代码来源:open_test.go
示例16: TestVerifyStorageFails
func (s *verifyStorageSuite) TestVerifyStorageFails(c *gc.C) {
defer testing.MakeFakeHome(c, existingEnv, "existing").Restore()
ctx := testing.Context(c)
environ, err := environs.PrepareFromName("test", ctx, configstore.NewMem())
c.Assert(err, gc.IsNil)
stor := environ.Storage()
someError := errors.Unauthorizedf("you shall not pass")
dummy.Poison(stor, environs.VerificationFilename, someError)
err = environs.VerifyStorage(stor)
c.Assert(err, gc.Equals, environs.VerifyStorageError)
}
开发者ID:jameinel,项目名称:core,代码行数:12,代码来源:emptystorage_test.go
示例17: TestExistingEnvironmentNotOverwritten
// An existing environments.yaml will not be overwritten without
// the explicit -f option.
func (*InitSuite) TestExistingEnvironmentNotOverwritten(c *gc.C) {
defer testing.MakeFakeHome(c, existingEnv, "existing").Restore()
ctx := testing.Context(c)
code := cmd.Main(&InitCommand{}, ctx, nil)
c.Check(code, gc.Equals, 1)
errOut := ctx.Stderr.(*bytes.Buffer).String()
strippedOut := strings.Replace(errOut, "\n", "", -1)
c.Check(strippedOut, gc.Matches, ".*A juju environment configuration already exists.*")
environpath := testing.HomePath(".juju", "environments.yaml")
data, err := ioutil.ReadFile(environpath)
c.Assert(err, gc.IsNil)
c.Assert(string(data), gc.Equals, existingEnv)
}
开发者ID:jameinel,项目名称:core,代码行数:16,代码来源:init_test.go
示例18: SetUpTest
func (s *ImageMetadataSuite) SetUpTest(c *gc.C) {
s.LoggingSuite.SetUpTest(c)
os.Clearenv()
s.dir = c.MkDir()
// Create a fake certificate so azure test environment can be opened.
certfile, err := ioutil.TempFile(s.dir, "")
c.Assert(err, gc.IsNil)
filename := certfile.Name()
err = ioutil.WriteFile(filename, []byte("test certificate"), 0644)
c.Assert(err, gc.IsNil)
envConfig := strings.Replace(metadataTestEnvConfig, "/home/me/azure.pem", filename, -1)
s.home = testing.MakeFakeHome(c, envConfig)
s.PatchEnvironment("AWS_ACCESS_KEY_ID", "access")
s.PatchEnvironment("AWS_SECRET_ACCESS_KEY", "secret")
}
开发者ID:jameinel,项目名称:core,代码行数:15,代码来源:imagemetadata_test.go
示例19: TestExistingEnvironmentOverwritten
// An existing environments.yaml will be overwritten when -f is
// given explicitly.
func (*InitSuite) TestExistingEnvironmentOverwritten(c *gc.C) {
defer testing.MakeFakeHome(c, existingEnv, "existing").Restore()
ctx := testing.Context(c)
code := cmd.Main(&InitCommand{}, ctx, []string{"-f"})
c.Check(code, gc.Equals, 0)
stdOut := ctx.Stdout.(*bytes.Buffer).String()
strippedOut := strings.Replace(stdOut, "\n", "", -1)
c.Check(strippedOut, gc.Matches, ".*A boilerplate environment configuration file has been written.*")
environpath := testing.HomePath(".juju", "environments.yaml")
data, err := ioutil.ReadFile(environpath)
c.Assert(err, gc.IsNil)
strippedData := strings.Replace(string(data), "\n", "", -1)
c.Assert(strippedData, gc.Matches, ".*# This is the Juju config file, which you can use.*")
}
开发者ID:jameinel,项目名称:core,代码行数:17,代码来源:init_test.go
示例20: TestCheckEnvironment
func (s *checkEnvironmentSuite) TestCheckEnvironment(c *gc.C) {
defer testing.MakeFakeHome(c, checkEnv, "existing").Restore()
ctx := testing.Context(c)
environ, err := environs.PrepareFromName("test", ctx, configstore.NewMem())
c.Assert(err, gc.IsNil)
// VerifyStorage is sufficient for our tests and much simpler
// than Bootstrap which calls it.
stor := environ.Storage()
err = environs.VerifyStorage(stor)
c.Assert(err, gc.IsNil)
err = environs.CheckEnvironment(environ)
c.Assert(err, gc.IsNil)
}
开发者ID:jameinel,项目名称:core,代码行数:15,代码来源:open_test.go
注:本文中的github.com/wallyworld/core/testing.MakeFakeHome函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论