本文整理汇总了Golang中github.com/tsuru/commandmocker.Error函数的典型用法代码示例。如果您正苦于以下问题:Golang Error函数的具体用法?Golang Error怎么用?Golang Error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Error函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestNewBareShouldReturnMeaningfullErrorWhenBareCreationFails
func (s *S) TestNewBareShouldReturnMeaningfullErrorWhenBareCreationFails(c *gocheck.C) {
dir, err := commandmocker.Error("git", "cmd output", 1)
c.Assert(err, gocheck.IsNil)
defer commandmocker.Remove(dir)
err = newBare("foo")
c.Check(err, gocheck.NotNil)
got := err.Error()
expected := "Could not create git bare repository: exit status 1. cmd output"
c.Assert(got, gocheck.Equals, expected)
}
开发者ID:rfloriano,项目名称:gandalf,代码行数:10,代码来源:git_test.go
示例2: TestExecutedCmdFailure
func (s *S) TestExecutedCmdFailure(c *gocheck.C) {
var buf bytes.Buffer
tmpdir, err := commandmocker.Error("juju", "failed", 2)
c.Assert(err, gocheck.IsNil)
defer commandmocker.Remove(tmpdir)
app := testing.NewFakeApp("frases", "static", 1)
p := JujuProvisioner{}
err = p.ExecuteCommand(&buf, &buf, app, "ls", "-l")
c.Assert(err, gocheck.NotNil)
c.Assert(err.Error(), gocheck.Equals, "exit status 2")
c.Assert(buf.String(), gocheck.Equals, "failed\n")
}
开发者ID:renanoliveira,项目名称:tsuru,代码行数:12,代码来源:provisioner_test.go
示例3: TestNewShouldNotStoreRepoInDbWhenBareCreationFails
func (s *S) TestNewShouldNotStoreRepoInDbWhenBareCreationFails(c *gocheck.C) {
dir, err := commandmocker.Error("git", "", 1)
c.Check(err, gocheck.IsNil)
defer commandmocker.Remove(dir)
r, err := New("myRepo", []string{"pumpkin"}, true)
c.Check(err, gocheck.NotNil)
conn, err := db.Conn()
c.Assert(err, gocheck.IsNil)
defer conn.Close()
err = conn.Repository().Find(bson.M{"_id": r.Name}).One(&r)
c.Assert(err, gocheck.ErrorMatches, "^not found$")
}
开发者ID:kenpu,项目名称:gandalf,代码行数:12,代码来源:repository_test.go
示例4: TestRemoveUnitFailure
func (s *S) TestRemoveUnitFailure(c *gocheck.C) {
tmpdir, err := commandmocker.Error("juju", "juju failed", 66)
c.Assert(err, gocheck.IsNil)
defer commandmocker.Remove(tmpdir)
app := testing.NewFakeApp("something", "rush", 1)
p := JujuProvisioner{}
err = p.RemoveUnit(app, "something/0")
c.Assert(err, gocheck.NotNil)
e, ok := err.(*provision.Error)
c.Assert(ok, gocheck.Equals, true)
c.Assert(e.Reason, gocheck.Equals, "juju failed")
c.Assert(e.Err.Error(), gocheck.Equals, "exit status 66")
}
开发者ID:renanoliveira,项目名称:tsuru,代码行数:13,代码来源:provisioner_test.go
示例5: TestRemoveUnitUnknownByJuju
func (s *S) TestRemoveUnitUnknownByJuju(c *gocheck.C) {
output := `013-01-11 20:02:07,883 INFO Connecting to environment...
2013-01-11 20:02:10,147 INFO Connected to environment.
2013-01-11 20:02:10,160 ERROR Service unit 'two/2' was not found`
tmpdir, err := commandmocker.Error("juju", output, 1)
c.Assert(err, gocheck.IsNil)
defer commandmocker.Remove(tmpdir)
app := testing.NewFakeApp("two", "rush", 3)
p := JujuProvisioner{}
err = p.RemoveUnit(app, "two/2")
c.Assert(err, gocheck.IsNil)
c.Assert(commandmocker.Ran(tmpdir), gocheck.Equals, true)
}
开发者ID:renanoliveira,项目名称:tsuru,代码行数:13,代码来源:provisioner_test.go
示例6: TestDestroyFailure
func (s *S) TestDestroyFailure(c *gocheck.C) {
tmpdir, err := commandmocker.Error("juju", "juju failed to destroy the machine", 25)
c.Assert(err, gocheck.IsNil)
defer commandmocker.Remove(tmpdir)
app := testing.NewFakeApp("idioglossia", "static", 1)
p := JujuProvisioner{}
err = p.Destroy(app)
c.Assert(err, gocheck.NotNil)
pErr, ok := err.(*provision.Error)
c.Assert(ok, gocheck.Equals, true)
c.Assert(pErr.Reason, gocheck.Equals, "juju failed to destroy the machine")
c.Assert(pErr.Err.Error(), gocheck.Equals, "exit status 25")
}
开发者ID:renanoliveira,项目名称:tsuru,代码行数:13,代码来源:provisioner_test.go
示例7: TestCollectStatusFailure
func (s *S) TestCollectStatusFailure(c *gocheck.C) {
tmpdir, err := commandmocker.Error("juju", "juju failed", 1)
c.Assert(err, gocheck.IsNil)
defer commandmocker.Remove(tmpdir)
p := JujuProvisioner{}
_, err = p.CollectStatus()
c.Assert(err, gocheck.NotNil)
pErr, ok := err.(*provision.Error)
c.Assert(ok, gocheck.Equals, true)
c.Assert(pErr.Reason, gocheck.Equals, "juju failed")
c.Assert(pErr.Err.Error(), gocheck.Equals, "exit status 1")
c.Assert(commandmocker.Ran(tmpdir), gocheck.Equals, true)
}
开发者ID:rochacon,项目名称:tsuru,代码行数:13,代码来源:collector_test.go
示例8: TestAddUnitsFailure
func (s *S) TestAddUnitsFailure(c *gocheck.C) {
tmpdir, err := commandmocker.Error("juju", "juju failed", 1)
c.Assert(err, gocheck.IsNil)
defer commandmocker.Remove(tmpdir)
app := testing.NewFakeApp("headlong", "rush", 1)
p := JujuProvisioner{}
units, err := p.AddUnits(app, 1)
c.Assert(units, gocheck.IsNil)
c.Assert(err, gocheck.NotNil)
e, ok := err.(*provision.Error)
c.Assert(ok, gocheck.Equals, true)
c.Assert(e.Reason, gocheck.Equals, "juju failed")
c.Assert(e.Err.Error(), gocheck.Equals, "exit status 1")
}
开发者ID:renanoliveira,项目名称:tsuru,代码行数:14,代码来源:provisioner_test.go
示例9: TestProvisionFailure
func (s *S) TestProvisionFailure(c *gocheck.C) {
config.Set("juju:charms-path", "/home/charms")
defer config.Unset("juju:charms-path")
tmpdir, err := commandmocker.Error("juju", "juju failed", 1)
c.Assert(err, gocheck.IsNil)
defer commandmocker.Remove(tmpdir)
app := testing.NewFakeApp("trace", "python", 0)
p := JujuProvisioner{}
err = p.Provision(app)
c.Assert(err, gocheck.NotNil)
pErr, ok := err.(*provision.Error)
c.Assert(ok, gocheck.Equals, true)
c.Assert(pErr.Reason, gocheck.Equals, "juju failed")
c.Assert(pErr.Err.Error(), gocheck.Equals, "exit status 1")
}
开发者ID:renanoliveira,项目名称:tsuru,代码行数:15,代码来源:provisioner_test.go
示例10: TestStartFailure
func (s *S) TestStartFailure(c *gocheck.C) {
// h := &testing.TestHandler{}
// gandalfServer := testing.StartGandalfTestServer(h)
// defer gandalfServer.Close()
tmpdir, err := commandmocker.Error("juju", "juju failed to run command", 25)
c.Assert(err, gocheck.IsNil)
defer commandmocker.Remove(tmpdir)
app := testing.NewFakeApp("cribcaged", "python", 1)
p := JujuProvisioner{}
err = p.Start(app)
c.Assert(err, gocheck.NotNil)
pErr, ok := err.(*provision.Error)
c.Assert(ok, gocheck.Equals, true)
c.Assert(pErr.Reason, gocheck.Equals, "juju failed to run command\n")
c.Assert(pErr.Err.Error(), gocheck.Equals, "exit status 25")
}
开发者ID:renanoliveira,项目名称:tsuru,代码行数:16,代码来源:provisioner_test.go
示例11: ExampleAdd
// This example demonstrates the mocking of the SSH command.
func ExampleAdd() {
msg := "HELP!"
path, err := commandmocker.Error("ssh", msg, 1)
if err != nil {
panic(err)
}
defer commandmocker.Remove(path)
cmd := exec.Command("ssh", "-l", "root", "127.0.0.1")
out, err := cmd.CombinedOutput()
fmt.Println(err)
fmt.Printf("%s\n", out)
fmt.Println(commandmocker.Parameters(path))
fmt.Println(commandmocker.Ran(path))
// Output:
// exit status 1
// HELP!
// [-l root 127.0.0.1]
// true
}
开发者ID:tsuru,项目名称:commandmocker,代码行数:20,代码来源:example_test.go
示例12: TestInstanceAgenstConfigHealerHeal
func (s *S) TestInstanceAgenstConfigHealerHeal(c *gocheck.C) {
server, err := ec2test.NewServer()
c.Assert(err, gocheck.IsNil)
defer server.Quit()
id := server.NewInstances(1, "small", "ami-123", ec2.InstanceState{Code: 16, Name: "running"}, nil)[0]
p := JujuProvisioner{}
m := machine{
AgentState: "not-started",
IPAddress: "localhost",
InstanceID: id,
InstanceState: "running",
}
p.saveBootstrapMachine(m)
collection := p.bootstrapCollection()
defer collection.Close()
defer collection.Remove(m)
a := app.App{
Name: "as_i_rise",
Units: []app.Unit{{Name: "as_i_rise/0", State: "down", Ip: "server-1081.novalocal"}},
}
err = s.conn.Apps().Insert(&a)
c.Assert(err, gocheck.IsNil)
defer s.conn.Apps().Remove(bson.M{"name": "as_i_rise"})
sshTmpdir, err := commandmocker.Error("ssh", "", 1)
c.Assert(err, gocheck.IsNil)
defer commandmocker.Remove(sshTmpdir)
h := instanceAgentsConfigHealer{}
auth := aws.Auth{AccessKey: "access", SecretKey: "secret"}
region := aws.SAEast
region.EC2Endpoint = server.URL()
h.e = ec2.New(auth, region)
err = h.Heal()
c.Assert(err, gocheck.IsNil)
sshOutput := []string{
"-o",
"StrictHostKeyChecking no",
"-q",
"-l",
"ubuntu",
"server-1081.novalocal",
"grep",
"i-0.internal.invalid",
"/etc/init/juju-machine-agent.conf",
"-o",
"StrictHostKeyChecking no",
"-q",
"-l",
"ubuntu",
"server-1081.novalocal",
"sudo",
"sed",
"-i",
"'s/env JUJU_ZOOKEEPER=.*/env JUJU_ZOOKEEPER=\"i-0.internal.invalid:2181\"/g'",
"/etc/init/juju-machine-agent.conf",
"-o",
"StrictHostKeyChecking no",
"-q",
"-l",
"ubuntu",
"server-1081.novalocal",
"grep",
"i-0.internal.invalid",
"/etc/init/juju-as_i_rise-0.conf",
"-o",
"StrictHostKeyChecking no",
"-q",
"-l",
"ubuntu",
"server-1081.novalocal",
"sudo",
"sed",
"-i",
"'s/env JUJU_ZOOKEEPER=.*/env JUJU_ZOOKEEPER=\"i-0.internal.invalid:2181\"/g'",
"/etc/init/juju-as_i_rise-0.conf",
}
c.Assert(commandmocker.Ran(sshTmpdir), gocheck.Equals, true)
c.Assert(commandmocker.Parameters(sshTmpdir), gocheck.DeepEquals, sshOutput)
}
开发者ID:rochacon,项目名称:tsuru,代码行数:78,代码来源:healer_test.go
注:本文中的github.com/tsuru/commandmocker.Error函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论