-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathssh_test.go
46 lines (36 loc) · 851 Bytes
/
ssh_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package gossh
import (
"github.com/stretchr/testify/require"
"github.com/treeforest/logger"
"testing"
)
var conn *SSH
func TestMain(m *testing.M) {
var err error
conn, err = Connect("192.168.1.20", 22, "tony", "1234qwer.")
if err != nil {
panic(err)
}
defer conn.Close()
conn.Log = logger.Debugf
m.Run()
}
func TestSSH_UserHomeDir(t *testing.T) {
home, err := conn.UserHomeDir()
require.NoError(t, err)
t.Logf("home dir: %s", home)
}
func TestSSH_Upload(t *testing.T) {
err := conn.Upload("./ssh.go", "~/")
require.NoError(t, err)
err = conn.Upload("./tmp", "/home/tony/tmp")
require.NoError(t, err)
}
func TestSSH_Download(t *testing.T) {
err := conn.Download("~/tmp", "./tmp")
require.NoError(t, err)
}
func Test_deleteFileLines(t *testing.T) {
err := deleteFileLines("test.txt", []int{2})
require.NoError(t, err)
}