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


Golang testing.RunCommand函數代碼示例

本文整理匯總了Golang中launchpad/net/juju-core/testing.RunCommand函數的典型用法代碼示例。如果您正苦於以下問題:Golang RunCommand函數的具體用法?Golang RunCommand怎麽用?Golang RunCommand使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了RunCommand函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: TestChangeAsCommandPair

func (s *SetEnvironmentSuite) TestChangeAsCommandPair(c *C) {
	_, err := testing.RunCommand(c, &SetEnvironmentCommand{}, []string{"default-series=raring"})
	c.Assert(err, IsNil)

	context, err := testing.RunCommand(c, &GetEnvironmentCommand{}, []string{"default-series"})
	c.Assert(err, IsNil)
	output := strings.TrimSpace(testing.Stdout(context))

	c.Assert(output, Equals, "raring")
}
開發者ID:rif,項目名稱:golang-stuff,代碼行數:10,代碼來源:environment_test.go

示例2: runDebugLog

func runDebugLog(c *C, args ...string) (*DebugLogCommand, error) {
	cmd := &DebugLogCommand{
		sshCmd: &dummySSHCommand{},
	}
	_, err := testing.RunCommand(c, cmd, args)
	return cmd, err
}
開發者ID:rif,項目名稱:golang-stuff,代碼行數:7,代碼來源:debuglog_test.go

示例3: TestSettingWritesFile

func (*SwitchSimpleSuite) TestSettingWritesFile(c *C) {
	defer testing.MakeFakeHome(c, testing.MultipleEnvConfig).Restore()
	context, err := testing.RunCommand(c, &SwitchCommand{}, []string{"erewhemos-2"})
	c.Assert(err, IsNil)
	c.Assert(testing.Stdout(context), Equals, "Changed default environment from \"erewhemos\" to \"erewhemos-2\"\n")
	c.Assert(readCurrentEnvironment(), Equals, "erewhemos-2")
}
開發者ID:johnvilsack,項目名稱:golang-stuff,代碼行數:7,代碼來源:switch_test.go

示例4: TestListEnvironments

func (*SwitchSimpleSuite) TestListEnvironments(c *C) {
	defer testing.MakeFakeHome(c, testing.MultipleEnvConfig).Restore()
	context, err := testing.RunCommand(c, &SwitchCommand{}, []string{"--list"})
	c.Assert(err, IsNil)
	c.Assert(testing.Stdout(context), Matches, "Current environment: \"erewhemos\"(.|\n)*")
	c.Assert(testing.Stdout(context), Matches, "(.|\n)*"+expectedEnvironments)
}
開發者ID:johnvilsack,項目名稱:golang-stuff,代碼行數:7,代碼來源:switch_test.go

示例5: TestShowsJujuEnv

func (*SwitchSimpleSuite) TestShowsJujuEnv(c *C) {
	defer testing.MakeFakeHome(c, testing.MultipleEnvConfig).Restore()
	os.Setenv("JUJU_ENV", "using-env")
	context, err := testing.RunCommand(c, &SwitchCommand{}, nil)
	c.Assert(err, IsNil)
	c.Assert(testing.Stdout(context), Equals, "Current environment: \"using-env\" (from JUJU_ENV)\n")
}
開發者ID:johnvilsack,項目名稱:golang-stuff,代碼行數:7,代碼來源:switch_test.go

示例6: TestChangeDefaultSeries

func (s *SetEnvironmentSuite) TestChangeDefaultSeries(c *C) {
	_, err := testing.RunCommand(c, &SetEnvironmentCommand{}, []string{"default-series=raring"})
	c.Assert(err, IsNil)

	stateConfig, err := s.State.EnvironConfig()
	c.Assert(err, IsNil)
	c.Assert(stateConfig.DefaultSeries(), Equals, "raring")
}
開發者ID:rif,項目名稱:golang-stuff,代碼行數:8,代碼來源:environment_test.go

示例7: TestImmutableConfigValues

func (s *SetEnvironmentSuite) TestImmutableConfigValues(c *C) {
	for name, value := range immutableConfigTests {
		param := fmt.Sprintf("%s=%s", name, value)
		_, err := testing.RunCommand(c, &SetEnvironmentCommand{}, []string{param})
		errorPattern := fmt.Sprintf("cannot change %s from .* to %q", name, value)
		c.Assert(err, ErrorMatches, errorPattern)
	}
}
開發者ID:rif,項目名稱:golang-stuff,代碼行數:8,代碼來源:environment_test.go

示例8: TestCurrentEnvironmentHasPrecidence

func (*SwitchSimpleSuite) TestCurrentEnvironmentHasPrecidence(c *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, IsNil)
	c.Assert(testing.Stdout(context), Equals, "Current environment: \"fubar\"\n")
}
開發者ID:johnvilsack,項目名稱:golang-stuff,代碼行數:8,代碼來源:switch_test.go

示例9: TestJujuEnvOverCurrentEnvironment

func (*SwitchSimpleSuite) TestJujuEnvOverCurrentEnvironment(c *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, IsNil)
	c.Assert(testing.Stdout(context), Equals, "Current environment: \"using-env\" (from JUJU_ENV)\n")
}
開發者ID:johnvilsack,項目名稱:golang-stuff,代碼行數:9,代碼來源:switch_test.go

示例10: TestRunDeprecationWarning

func (s *RelationSetSuite) TestRunDeprecationWarning(c *C) {
	hctx := s.GetHookContext(c, 0, "")
	com, _ := jujuc.NewCommand(hctx, "relation-set")
	// The rel= is needed to make this a valid command.
	ctx, err := testing.RunCommand(c, com, []string{"--format", "foo", "rel="})

	c.Assert(err, IsNil)
	c.Assert(testing.Stdout(ctx), Equals, "")
	c.Assert(testing.Stderr(ctx), Equals, "--format flag deprecated for command \"relation-set\"")
}
開發者ID:rif,項目名稱:golang-stuff,代碼行數:10,代碼來源:relation-set_test.go

示例11: TestChangeMultipleValues

func (s *SetEnvironmentSuite) TestChangeMultipleValues(c *C) {
	_, err := testing.RunCommand(c, &SetEnvironmentCommand{}, []string{"default-series=spartan", "broken=nope", "secret=sekrit"})
	c.Assert(err, IsNil)

	stateConfig, err := s.State.EnvironConfig()
	c.Assert(err, IsNil)
	attrs := stateConfig.AllAttrs()
	c.Assert(attrs["default-series"].(string), Equals, "spartan")
	c.Assert(attrs["broken"].(string), Equals, "nope")
	c.Assert(attrs["secret"].(string), Equals, "sekrit")
}
開發者ID:rif,項目名稱:golang-stuff,代碼行數:11,代碼來源:environment_test.go

示例12: TestAllValues

func (s *GetEnvironmentSuite) TestAllValues(c *C) {

	context, _ := testing.RunCommand(c, &GetEnvironmentCommand{}, []string{})
	output := strings.TrimSpace(testing.Stdout(context))

	// Make sure that all the environment keys are there.
	any := "(.|\n)*" // because . doesn't match new lines.
	for key := range s.Conn.Environ.Config().AllAttrs() {
		c.Assert(output, Matches, fmt.Sprintf("%s%s: %s", any, key, any))
	}
}
開發者ID:rif,項目名稱:golang-stuff,代碼行數:11,代碼來源:environment_test.go

示例13: TestUpgradeJujuWithRealUpload

func (s *UpgradeJujuSuite) TestUpgradeJujuWithRealUpload(c *C) {
	s.Reset(c)
	_, err := coretesting.RunCommand(c, &UpgradeJujuCommand{}, []string{"--upload-tools"})
	c.Assert(err, IsNil)
	vers := version.Current
	vers.Build = 1
	name := tools.StorageName(vers)
	r, err := s.Conn.Environ.Storage().Get(name)
	c.Assert(err, IsNil)
	r.Close()
}
開發者ID:CSRedRat,項目名稱:juju-core,代碼行數:11,代碼來源:upgradejuju_test.go

示例14: TestSingleValue

func (s *GetEnvironmentSuite) TestSingleValue(c *C) {

	for _, t := range singleValueTests {
		context, err := testing.RunCommand(c, &GetEnvironmentCommand{}, []string{t.key})
		if t.err != "" {
			c.Assert(err, ErrorMatches, t.err)
		} else {
			output := strings.TrimSpace(testing.Stdout(context))
			c.Assert(err, IsNil)
			c.Assert(output, Equals, t.output)
		}
	}
}
開發者ID:rif,項目名稱:golang-stuff,代碼行數:13,代碼來源:environment_test.go

示例15: TestLogDeprecation

func (s *JujuLogSuite) TestLogDeprecation(c *C) {
	com := newJujuLogCommand(c)
	ctx, err := testing.RunCommand(c, com, []string{"--format", "foo", "msg"})
	c.Assert(err, IsNil)
	c.Assert(testing.Stderr(ctx), Equals, "--format flag deprecated for command \"juju-log\"")
}
開發者ID:rif,項目名稱:golang-stuff,代碼行數:6,代碼來源:juju-log_test.go


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