forked from fl00r/go-tarantool-1.6
-
Notifications
You must be signed in to change notification settings - Fork 63
Expand file tree
/
Copy pathclient_tools_test.go
More file actions
46 lines (39 loc) · 993 Bytes
/
client_tools_test.go
File metadata and controls
46 lines (39 loc) · 993 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
36
37
38
39
40
41
42
43
44
45
46
package tarantool_test
import (
"bytes"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/vmihailenco/msgpack/v5"
"github.com/tarantool/go-tarantool/v3"
)
func TestOperations_EncodeMsgpack(t *testing.T) {
ops := tarantool.NewOperations().
Add(1, 2).
Subtract(1, 2).
BitwiseAnd(1, 2).
BitwiseOr(1, 2).
BitwiseXor(1, 2).
Splice(1, 2, 3, "a").
Insert(1, 2).
Delete(1, 2).
Assign(1, 2)
refOps := []any{
[]any{"+", 1, 2},
[]any{"-", 1, 2},
[]any{"&", 1, 2},
[]any{"|", 1, 2},
[]any{"^", 1, 2},
[]any{":", 1, 2, 3, "a"},
[]any{"!", 1, 2},
[]any{"#", 1, 2},
[]any{"=", 1, 2},
}
var refBuf bytes.Buffer
encRef := msgpack.NewEncoder(&refBuf)
require.NoError(t, encRef.Encode(refOps), "error while encoding")
var buf bytes.Buffer
enc := msgpack.NewEncoder(&buf)
require.NoError(t, enc.Encode(ops), "error while encoding")
assert.Equal(t, refBuf.Bytes(), buf.Bytes(), "encode response is wrong")
}