當前位置: 首頁>>代碼示例>>Golang>>正文


Golang testing.MakeFakeHome函數代碼示例

本文整理匯總了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)
}
開發者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


注:本文中的github.com/wallyworld/core/testing.MakeFakeHome函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。