本文整理汇总了Golang中github.com/wallyworld/core/testing.RunCommand函数的典型用法代码示例。如果您正苦于以下问题:Golang RunCommand函数的具体用法?Golang RunCommand怎么用?Golang RunCommand使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RunCommand函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestRemoveUser
func (s *RemoveUserSuite) TestRemoveUser(c *gc.C) {
_, err := testing.RunCommand(c, &AddUserCommand{}, []string{"foobar", "password"})
c.Assert(err, gc.IsNil)
_, err = testing.RunCommand(c, &RemoveUserCommand{}, []string{"foobar"})
c.Assert(err, gc.IsNil)
}
开发者ID:jameinel,项目名称:core,代码行数:7,代码来源:removeuser_test.go
示例2: TestAddUser
func (s *AddUserSuite) TestAddUser(c *gc.C) {
_, err := testing.RunCommand(c, &AddUserCommand{}, []string{"foobar", "password"})
c.Assert(err, gc.IsNil)
_, err = testing.RunCommand(c, &AddUserCommand{}, []string{"foobar", "newpassword"})
c.Assert(err, gc.ErrorMatches, "Failed to create user: user already exists")
}
开发者ID:jameinel,项目名称:core,代码行数:8,代码来源:adduser_test.go
示例3: TestChangeAsCommandPair
func (s *SetEnvironmentSuite) TestChangeAsCommandPair(c *gc.C) {
_, err := testing.RunCommand(c, &SetEnvironmentCommand{}, []string{"default-series=raring"})
c.Assert(err, gc.IsNil)
context, err := testing.RunCommand(c, &GetEnvironmentCommand{}, []string{"default-series"})
c.Assert(err, gc.IsNil)
output := strings.TrimSpace(testing.Stdout(context))
c.Assert(output, gc.Equals, "raring")
}
开发者ID:jameinel,项目名称:core,代码行数:10,代码来源:environment_test.go
示例4: 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
示例5: 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
示例6: TestAllMachines
func (s *RunSuite) TestAllMachines(c *gc.C) {
mock := s.setupMockAPI()
mock.setMachinesAlive("0", "1")
response0 := mockResponse{
stdout: "megatron\n",
machineId: "0",
}
response1 := mockResponse{
error: "command timed out",
machineId: "1",
}
mock.setResponse("0", response0)
unformatted := ConvertRunResults([]params.RunResult{
makeRunResult(response0),
makeRunResult(response1),
})
jsonFormatted, err := cmd.FormatJson(unformatted)
c.Assert(err, gc.IsNil)
context, err := testing.RunCommand(c, &RunCommand{}, []string{
"--format=json", "--all", "hostname",
})
c.Assert(err, gc.IsNil)
c.Check(testing.Stdout(context), gc.Equals, string(jsonFormatted)+"\n")
}
开发者ID:jameinel,项目名称:core,代码行数:28,代码来源:run_test.go
示例7: 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
示例8: TestRunForMachineAndUnit
func (s *RunSuite) TestRunForMachineAndUnit(c *gc.C) {
mock := s.setupMockAPI()
machineResponse := mockResponse{
stdout: "megatron\n",
machineId: "0",
}
unitResponse := mockResponse{
stdout: "bumblebee",
machineId: "1",
unitId: "unit/0",
}
mock.setResponse("0", machineResponse)
mock.setResponse("unit/0", unitResponse)
unformatted := ConvertRunResults([]params.RunResult{
makeRunResult(machineResponse),
makeRunResult(unitResponse),
})
jsonFormatted, err := cmd.FormatJson(unformatted)
c.Assert(err, gc.IsNil)
context, err := testing.RunCommand(c, &RunCommand{}, []string{
"--format=json", "--machine=0", "--unit=unit/0", "hostname",
})
c.Assert(err, gc.IsNil)
c.Check(testing.Stdout(context), gc.Equals, string(jsonFormatted)+"\n")
}
开发者ID:jameinel,项目名称:core,代码行数:29,代码来源:run_test.go
示例9: TestResolved
func (s *retryProvisioningSuite) TestResolved(c *gc.C) {
m, err := s.State.AddOneMachine(state.MachineTemplate{
Series: "quantal",
Jobs: []state.MachineJob{state.JobManageEnviron},
})
c.Assert(err, gc.IsNil)
err = m.SetStatus(params.StatusError, "broken", nil)
c.Assert(err, gc.IsNil)
_, err = s.State.AddOneMachine(state.MachineTemplate{
Series: "quantal",
Jobs: []state.MachineJob{state.JobHostUnits},
})
c.Assert(err, gc.IsNil)
for i, t := range resolvedMachineTests {
c.Logf("test %d: %v", i, t.args)
context, err := testing.RunCommand(c, &RetryProvisioningCommand{}, t.args)
if t.err != "" {
c.Check(err, gc.ErrorMatches, t.err)
continue
} else {
c.Check(err, gc.IsNil)
}
output := testing.Stderr(context)
stripped := strings.Replace(output, "\n", "", -1)
c.Check(stripped, gc.Equals, t.stdErr)
if t.args[0] == "0" {
status, info, data, err := m.Status()
c.Check(err, gc.IsNil)
c.Check(status, gc.Equals, params.StatusError)
c.Check(info, gc.Equals, "broken")
c.Check(data["transient"], jc.IsTrue)
}
}
}
开发者ID:jameinel,项目名称:core,代码行数:35,代码来源:retryprovisioning_test.go
示例10: TestUnsetEnvironment
func (s *UnsetEnvironmentSuite) TestUnsetEnvironment(c *gc.C) {
for _, t := range unsetEnvTests {
c.Logf("testing unset-env %v", t.args)
s.initConfig(c)
_, err := testing.RunCommand(c, &UnsetEnvironmentCommand{}, t.args)
if t.err != "" {
c.Assert(err, gc.ErrorMatches, t.err)
} else {
c.Assert(err, gc.IsNil)
}
if len(t.expected)+len(t.unexpected) != 0 {
stateConfig, err := s.State.EnvironConfig()
c.Assert(err, gc.IsNil)
for k, v := range t.expected {
vstate, ok := stateConfig.AllAttrs()[k]
c.Assert(ok, jc.IsTrue)
c.Assert(vstate, gc.Equals, v)
}
for _, k := range t.unexpected {
_, ok := stateConfig.AllAttrs()[k]
c.Assert(ok, jc.IsFalse)
}
}
}
}
开发者ID:jameinel,项目名称:core,代码行数:25,代码来源:environment_test.go
示例11: TestChangeBooleanAttribute
func (s *SetEnvironmentSuite) TestChangeBooleanAttribute(c *gc.C) {
_, err := testing.RunCommand(c, &SetEnvironmentCommand{}, []string{"ssl-hostname-verification=false"})
c.Assert(err, gc.IsNil)
stateConfig, err := s.State.EnvironConfig()
c.Assert(err, gc.IsNil)
c.Assert(stateConfig.SSLHostnameVerification(), gc.Equals, false)
}
开发者ID:jameinel,项目名称:core,代码行数:8,代码来源:environment_test.go
示例12: TestLogOutput
func (s *DebugLogSuite) TestLogOutput(c *gc.C) {
s.PatchValue(&getDebugLogAPI, func(envName string) (DebugLogAPI, error) {
return &fakeDebugLogAPI{log: "this is the log output"}, nil
})
ctx, err := testing.RunCommand(c, &DebugLogCommand{}, nil)
c.Assert(err, gc.IsNil)
c.Assert(testing.Stdout(ctx), gc.Equals, "this is the log output")
}
开发者ID:jameinel,项目名称:core,代码行数:8,代码来源:debuglog_test.go
示例13: 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
示例14: TestJenvJsonFileOutput
func (s *AddUserSuite) TestJenvJsonFileOutput(c *gc.C) {
expected := `{"User":"foobar","Password":"password","state-servers":null,"ca-cert":""}
`
ctx, err := testing.RunCommand(c, &AddUserCommand{}, []string{"foobar", "password", "--format", "json"})
c.Assert(err, gc.IsNil)
stdout := ctx.Stdout.(*bytes.Buffer).String()
c.Assert(stdout, gc.DeepEquals, expected)
}
开发者ID:jameinel,项目名称:core,代码行数:8,代码来源:adduser_test.go
示例15: TestImmutableConfigValues
func (s *SetEnvironmentSuite) TestImmutableConfigValues(c *gc.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 [\"]?%v[\"]?", name, value)
c.Assert(err, gc.ErrorMatches, errorPattern)
}
}
开发者ID:jameinel,项目名称:core,代码行数:8,代码来源:environment_test.go
示例16: TestDestroyEnvironmentCommandEmptyJenv
func (s *destroyEnvSuite) TestDestroyEnvironmentCommandEmptyJenv(c *gc.C) {
_, err := s.ConfigStore.CreateInfo("emptyenv")
c.Assert(err, gc.IsNil)
context, err := coretesting.RunCommand(c, new(DestroyEnvironmentCommand), []string{"-e", "emptyenv"})
c.Assert(err, gc.IsNil)
c.Assert(coretesting.Stderr(context), gc.Equals, "removing empty environment file\n")
}
开发者ID:jameinel,项目名称:core,代码行数:9,代码来源:destroyenvironment_test.go
示例17: TestMissingSocket
func (s *RunTestSuite) TestMissingSocket(c *gc.C) {
s.PatchValue(&AgentDir, c.MkDir())
testAgentDir := filepath.Join(AgentDir, "foo")
err := os.Mkdir(testAgentDir, 0755)
c.Assert(err, gc.IsNil)
_, err = testing.RunCommand(c, &RunCommand{}, []string{"foo", "bar"})
c.Assert(err, gc.ErrorMatches, `dial unix .*/run.socket: no such file or directory`)
}
开发者ID:jameinel,项目名称:core,代码行数:9,代码来源:run_test.go
示例18: TestGeneratePassword
func (s *AddUserSuite) TestGeneratePassword(c *gc.C) {
ctx, err := testing.RunCommand(c, &AddUserCommand{}, []string{"foobar"})
c.Assert(err, gc.IsNil)
stdout := ctx.Stdout.(*bytes.Buffer).Bytes()
var d map[string]interface{}
err = goyaml.Unmarshal(stdout, &d)
c.Assert(err, gc.IsNil)
c.Assert(d["user"], gc.DeepEquals, "foobar")
}
开发者ID:jameinel,项目名称:core,代码行数:9,代码来源:adduser_test.go
示例19: TestNoContext
func (s *RunTestSuite) TestNoContext(c *gc.C) {
s.PatchValue(&LockDir, c.MkDir())
s.PatchValue(&AgentDir, c.MkDir())
ctx, err := testing.RunCommand(c, &RunCommand{}, []string{"--no-context", "echo done"})
c.Assert(err, jc.Satisfies, cmd.IsRcPassthroughError)
c.Assert(err, gc.ErrorMatches, "subprocess encountered error code 0")
c.Assert(testing.Stdout(ctx), gc.Equals, "done\n")
}
开发者ID:jameinel,项目名称:core,代码行数:9,代码来源:run_test.go
示例20: 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
注:本文中的github.com/wallyworld/core/testing.RunCommand函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论