drone-ssh/main_test.go
2016-01-01 21:36:08 +01:00

49 lines
738 B
Go

package main
import (
"io/ioutil"
"os"
"testing"
"github.com/drone/drone-go/drone"
)
var (
host = os.Getenv("TEST_SSH_HOST")
user = os.Getenv("TEST_SSH_USER")
key = os.Getenv("TEST_SSH_KEY")
)
func TestRun(t *testing.T) {
if len(host) == 0 {
t.Skipf("TEST_SSH_HOST not provided")
return
}
out, err := ioutil.ReadFile(key)
if err != nil {
t.Errorf("Unable to read or find a test privte key. %s", err)
}
params := &Params{
Commands: []string{"whoami", "time", "ps -ax"},
Login: user,
Host: drone.NewStringSlice(
[]string{
host,
},
),
}
keys := &drone.Key{
Private: string(out),
}
err = run(keys, params, host)
if err != nil {
t.Errorf("Unable to run SSH commands. %s.", err)
}
}