Skip to content

Commit 9731ddf

Browse files
authored
Add a test case for #1127 (#1242)
1 parent e8681f7 commit 9731ddf

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

tests/issues/1127_test.go

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package issues
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"testing"
7+
8+
"github.com/ClickHouse/clickhouse-go/v2"
9+
clickhouse_tests "github.com/ClickHouse/clickhouse-go/v2/tests"
10+
"github.com/stretchr/testify/assert"
11+
"github.com/stretchr/testify/require"
12+
)
13+
14+
func Test1127(t *testing.T) {
15+
var (
16+
conn, err = clickhouse_tests.GetConnection("issues", clickhouse.Settings{
17+
"max_execution_time": 60,
18+
"allow_experimental_object_type": true,
19+
}, nil, &clickhouse.Compression{
20+
Method: clickhouse.CompressionLZ4,
21+
})
22+
)
23+
require.NoError(t, err)
24+
25+
progressTotalRows := uint64(0)
26+
profileTotalRows := uint64(0)
27+
ctx := clickhouse.Context(context.Background(), clickhouse.WithProgress(func(p *clickhouse.Progress) {
28+
fmt.Println("progress: ", p)
29+
progressTotalRows += p.Rows
30+
}), clickhouse.WithProfileInfo(func(p *clickhouse.ProfileInfo) {
31+
fmt.Println("profile info: ", p)
32+
profileTotalRows += p.Rows
33+
}), clickhouse.WithLogs(func(log *clickhouse.Log) {
34+
fmt.Println("log info: ", log)
35+
}))
36+
37+
rows, err := conn.Query(ctx, "SELECT number from numbers(10000000) LIMIT 10000000")
38+
require.NoError(t, err)
39+
40+
defer rows.Close()
41+
for rows.Next() {
42+
}
43+
44+
require.NoError(t, rows.Err())
45+
assert.Equal(t, uint64(10000000), progressTotalRows)
46+
assert.Equal(t, uint64(10000000), profileTotalRows)
47+
}

0 commit comments

Comments
 (0)