-
Notifications
You must be signed in to change notification settings - Fork 34
/
session_test.go
44 lines (38 loc) · 1.08 KB
/
session_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
package roger
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestSessionCommand(t *testing.T) {
client, _ := NewRClient("localhost", 6311)
sess, err := client.GetSession()
defer sess.Close()
obj, err := sess.SendCommand("2.2").GetResultObject()
assert.Equal(t, obj, float64(2.2))
assert.Equal(t, err, nil)
}
func TestSessionEval(t *testing.T) {
client, _ := NewRClient("localhost", 6311)
sess, err := client.GetSession()
defer sess.Close()
obj, err := sess.Eval("2.2")
assert.Equal(t, obj, float64(2.2))
assert.Equal(t, err, nil)
}
func TestMultipleSessionCommands(t *testing.T) {
client, _ := NewRClient("localhost", 6311)
sess, err := client.GetSession()
defer sess.Close()
assert.Equal(t, err, nil)
sess.SendCommand("x <- 2.2")
obj, err := sess.SendCommand("x").GetResultObject()
assert.Equal(t, obj, float64(2.2))
assert.Equal(t, err, nil)
}
func TestSessionClose(t *testing.T) {
client, _ := NewRClient("localhost", 6311)
sess, err := client.GetSession()
sess.Close()
_, err = sess.SendCommand("2").GetResultObject()
assert.NotEqual(t, err, nil)
}