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
|
package proto
import (
"encoding/hex"
"testing"
"github.com/stretchr/testify/require"
)
func TestTableColumns_EncodeAware(t *testing.T) {
v := TableColumns{
First: "",
Second: "columns format version: 1\n1 columns:\n`id` UInt8\n",
}
var b Buffer
v.EncodeAware(&b, Version)
t.Log(hex.Dump(b.Buf))
t.Run("Golden", func(t *testing.T) {
Gold(t, v)
})
t.Run("Decode", func(t *testing.T) {
var dec TableColumns
buf := skipCode(t, b.Buf, int(ServerCodeTableColumns))
requireDecode(t, buf, aware(&dec))
require.Equal(t, dec, v)
requireNoShortRead(t, buf, aware(&dec))
})
}
|