• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang testing.MakeFakeHome函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang testing.MgoTestPackage函数代码示例发布时间:2022-05-28
下一篇:
Golang testing.InitCommand函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap