forked from bnhf/go-openvpn
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommand_test.go
More file actions
35 lines (29 loc) · 734 Bytes
/
command_test.go
File metadata and controls
35 lines (29 loc) · 734 Bytes
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
package mi_test
import (
"bufio"
"net"
"strings"
"testing"
mi "github.com/bnhf/go-openvpn/server/mi"
"github.com/stretchr/testify/assert"
)
var cResponsePid = `SUCCESS: pid=10869
`
func TestReadResponsePid(t *testing.T) {
reader := bufio.NewReader(strings.NewReader(cResponsePid))
response, err := mi.ReadResponse(reader)
assert.Nil(t, err)
pid, err := mi.ParsePid(response)
assert.Nil(t, err)
assert.Equal(t, int64(10869), pid)
}
func TestReadResponseFailure(t *testing.T) {
reader := bufio.NewReader(strings.NewReader(""))
_, err := mi.ReadResponse(reader)
assert.NotNil(t, err)
}
func TestSendCommandFailure(t *testing.T) {
conn := &net.IPConn{}
err := mi.SendCommand(conn, "dummy")
assert.NotNil(t, err)
}