30 lines
567 B
Go
30 lines
567 B
Go
package ssh
|
|
|
|
import (
|
|
"net"
|
|
"strconv"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestRun(t *testing.T) {
|
|
assert := assert.New(t)
|
|
addr := net.TCPAddr{IP: net.ParseIP("fd2f:5119:f2c::127"), Port: 22}
|
|
mgmt := NewManager("~/.ssh/id_rsa", 5*time.Second)
|
|
assert.NotNil(mgmt, "no new manager created")
|
|
|
|
client, err := mgmt.ConnectTo(addr)
|
|
assert.NoError(err)
|
|
client.Close()
|
|
|
|
result, err := mgmt.RunOn(addr, "echo 16")
|
|
assert.NoError(err)
|
|
|
|
str := SSHResultToString(result)
|
|
resultInt, _ := strconv.Atoi(str)
|
|
|
|
assert.Equal(16, resultInt)
|
|
}
|