-
Notifications
You must be signed in to change notification settings - Fork 62
/
node_funcs_param_test.go
70 lines (56 loc) · 1.45 KB
/
node_funcs_param_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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package goroslib
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestNodeSetGetParam(t *testing.T) {
for _, lang := range []string{
"cpp",
"go",
} {
t.Run(lang, func(t *testing.T) {
m := newContainerMaster(t)
defer m.close()
switch lang {
case "cpp":
p := newContainer(t, "node-setparam", m.IP())
defer p.close()
case "go":
n, err := NewNode(NodeConf{
Namespace: "/myns",
Name: "goroslib_set",
MasterAddress: m.IP() + ":11311",
})
require.NoError(t, err)
defer n.Close()
err = n.ParamSetBool("test_bool", true)
require.NoError(t, err)
err = n.ParamSetInt("test_int", 123)
require.NoError(t, err)
err = n.ParamSetString("test_string", "ABC")
require.NoError(t, err)
err = n.ParamSetFloat64("test_double", 32.5)
require.NoError(t, err)
}
n, err := NewNode(NodeConf{
Namespace: "/myns",
Name: "goroslib",
MasterAddress: m.IP() + ":11311",
})
require.NoError(t, err)
defer n.Close()
resb, err := n.ParamGetBool("test_bool")
require.NoError(t, err)
require.Equal(t, true, resb)
res1, err := n.ParamGetInt("test_int")
require.NoError(t, err)
require.Equal(t, 123, res1)
res2, err := n.ParamGetString("test_string")
require.NoError(t, err)
require.Equal(t, "ABC", res2)
res3, err := n.ParamGetFloat64("test_double")
require.NoError(t, err)
require.Equal(t, 32.5, res3)
})
}
}