Skip to content

Commit

Permalink
Add a test case for #1127 (#1242)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkaflik authored Mar 19, 2024
1 parent e8681f7 commit 9731ddf
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions tests/issues/1127_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package issues

import (
"context"
"fmt"
"testing"

"github.com/ClickHouse/clickhouse-go/v2"
clickhouse_tests "github.com/ClickHouse/clickhouse-go/v2/tests"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func Test1127(t *testing.T) {
var (
conn, err = clickhouse_tests.GetConnection("issues", clickhouse.Settings{
"max_execution_time": 60,
"allow_experimental_object_type": true,
}, nil, &clickhouse.Compression{
Method: clickhouse.CompressionLZ4,
})
)
require.NoError(t, err)

progressTotalRows := uint64(0)
profileTotalRows := uint64(0)
ctx := clickhouse.Context(context.Background(), clickhouse.WithProgress(func(p *clickhouse.Progress) {
fmt.Println("progress: ", p)
progressTotalRows += p.Rows
}), clickhouse.WithProfileInfo(func(p *clickhouse.ProfileInfo) {
fmt.Println("profile info: ", p)
profileTotalRows += p.Rows
}), clickhouse.WithLogs(func(log *clickhouse.Log) {
fmt.Println("log info: ", log)
}))

rows, err := conn.Query(ctx, "SELECT number from numbers(10000000) LIMIT 10000000")
require.NoError(t, err)

defer rows.Close()
for rows.Next() {
}

require.NoError(t, rows.Err())
assert.Equal(t, uint64(10000000), progressTotalRows)
assert.Equal(t, uint64(10000000), profileTotalRows)
}

0 comments on commit 9731ddf

Please sign in to comment.