test: improve testing.

This commit is contained in:
Bo-Yi Wu 2017-01-24 15:06:32 +08:00
parent 876c4c1cee
commit 95f777f22e

View File

@ -138,14 +138,30 @@ func TestWrongKeyFormat(t *testing.T) {
func TestSSHScriptFromKeyFile(t *testing.T) { func TestSSHScriptFromKeyFile(t *testing.T) {
plugin := Plugin{ plugin := Plugin{
Config: Config{ Config: Config{
Host: []string{"localhost"}, Host: []string{"localhost", "127.0.0.1"},
User: "drone-scp", User: "drone-scp",
Port: 22, Port: 22,
KeyPath: "./tests/.ssh/id_rsa", KeyPath: "./tests/.ssh/id_rsa",
Script: []string{"whoami"}, Script: []string{"whoami"},
Sleep: 1,
}, },
} }
err := plugin.Exec() err := plugin.Exec()
assert.Nil(t, err) assert.Nil(t, err)
} }
func TestSSHScriptRunError(t *testing.T) {
plugin := Plugin{
Config: Config{
Host: []string{"localhost"},
User: "drone-scp",
Port: 22,
KeyPath: "./tests/.ssh/id_rsa",
Script: []string{"whoami", "whoam"},
},
}
err := plugin.Exec()
assert.NotNil(t, err)
}