aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/ClickHouse/ch-go/proto/progress_test.go
blob: 998e4e05e3546509045a1d23bacd4db07a2f6065 (plain) (blame)
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
package proto

import (
	"testing"

	"github.com/stretchr/testify/assert"

	"github.com/ClickHouse/ch-go/internal/gold"
)

func TestProgress_EncodeAware(t *testing.T) {
	b := new(Buffer)
	v := Progress{
		Rows:       100,
		Bytes:      608120,
		TotalRows:  1000,
		WroteRows:  441,
		WroteBytes: 91023,
	}
	v.EncodeAware(b, Version)
	gold.Bytes(t, b.Buf, "progress")

	t.Run("DecodeAware", func(t *testing.T) {
		var dec Progress
		requireDecode(t, b.Buf, aware(&dec))
		assert.Equal(t, v, dec)
		requireNoShortRead(t, b.Buf, aware(&dec))
	})
}