fix: remove check error string.

This commit is contained in:
Bo-Yi Wu 2017-03-04 22:00:38 +08:00
parent e5dc646e5d
commit c6042000fd
2 changed files with 6 additions and 17 deletions

View File

@ -16,6 +16,7 @@ var wg sync.WaitGroup
const (
missingHostOrUser = "Error: missing server host or user"
missingPasswordOrKey = "Error: can't connect without a private SSH key or password"
commandTimeOut = "Error: command timeout"
)
type (
@ -91,9 +92,12 @@ func (p Plugin) Exec() error {
p.log(host, "commands: ", strings.Join(p.Config.Script, "\n"))
outStr, errStr, isTimeout, err := ssh.Run(strings.Join(p.Config.Script, "\n"), p.Config.CommandTimeout)
p.log(host, "outputs:", outStr)
if len(errStr) != 0 {
p.log(host, "errors:", outStr)
}
if !isTimeout || len(errStr) != 0 {
errChannel <- fmt.Errorf(errStr)
if !isTimeout {
errChannel <- fmt.Errorf(commandTimeOut)
}
if err != nil {

View File

@ -120,21 +120,6 @@ func TestSSHCommandTimeOut(t *testing.T) {
assert.NotNil(t, err)
}
func TestSSHCommandNotFound(t *testing.T) {
plugin := Plugin{
Config: Config{
Host: []string{"localhost"},
UserName: "drone-scp",
Port: 22,
KeyPath: "./tests/.ssh/id_rsa",
Script: []string{"whoami1234"},
},
}
err := plugin.Exec()
assert.NotNil(t, err)
}
func TestProxyCommand(t *testing.T) {
plugin := Plugin{
Config: Config{