add testing

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu 2017-08-01 12:00:06 +08:00
parent c279b5c136
commit e1cefccb1e

View File

@ -1,6 +1,7 @@
package main
import (
"os"
"testing"
"github.com/appleboy/easyssh-proxy"
@ -229,3 +230,28 @@ func TestSSHCommandExitCodeError(t *testing.T) {
err := plugin.Exec()
assert.NotNil(t, err)
}
func TestSetENV(t *testing.T) {
os.Setenv("FOO", "1")
plugin := Plugin{
Config: Config{
Host: []string{"localhost"},
UserName: "drone-scp",
Port: 22,
KeyPath: "./tests/.ssh/id_rsa",
Secrets: []string{"FOO"},
Envs: []string{"FOO"},
Script: []string{"whoami; echo $FOO"},
CommandTimeout: 1,
Proxy: easyssh.DefaultConfig{
Server: "localhost",
User: "drone-scp",
Port: "22",
KeyPath: "./tests/.ssh/id_rsa",
},
},
}
err := plugin.Exec()
assert.Nil(t, err)
}