Skip to content

Commit

Permalink
Merge pull request #204 from taosdata/merge/xftan/mainto3.0
Browse files Browse the repository at this point in the history
merge main to 3.0
  • Loading branch information
huskar-t authored Oct 24, 2023
2 parents 2ec7278 + a3e7562 commit a3d62aa
Show file tree
Hide file tree
Showing 27 changed files with 251 additions and 20 deletions.
19 changes: 19 additions & 0 deletions af/conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ func TestMain(m *testing.M) {
panic(err)
}
}

// @author: xftan
// @date: 2023/10/13 11:41
// @description: test af create database
func testDatabase(t *testing.T) *Connector {
db, err := Open("", "", "", "", 0)
if err != nil {
Expand Down Expand Up @@ -779,6 +783,9 @@ func TestOpenTSDBInsertJsonPayload(t *testing.T) {
}
}

// @author: xftan
// @date: 2023/10/13 11:12
// @description: test opentsdb json
func TestOpenTSDBInsertJsonPayloadWrong(t *testing.T) {
db := testDatabase(t)
defer db.Close()
Expand All @@ -797,6 +804,9 @@ func TestOpenTSDBInsertJsonPayloadWrong(t *testing.T) {
}
}

// @author: xftan
// @date: 2023/10/13 11:12
// @description: test stmt execute with reqID
func TestConnector_StmtExecuteWithReqID(t *testing.T) {
db := testDatabase(t)
defer db.Close()
Expand All @@ -822,6 +832,9 @@ func TestConnector_StmtExecuteWithReqID(t *testing.T) {
}
}

// @author: xftan
// @date: 2023/10/13 11:12
// @description: test stmt execute with reqID
func TestConnector_InsertStmtWithReqID(t *testing.T) {
db := testDatabase(t)
defer db.Close()
Expand Down Expand Up @@ -856,6 +869,9 @@ func TestConnector_InsertStmtWithReqID(t *testing.T) {

}

// @author: xftan
// @date: 2023/10/13 11:13
// @description: test execute with reqID
func TestConnector_ExecWithReqID(t *testing.T) {
db := testDatabase(t)
defer db.Close()
Expand All @@ -874,6 +890,9 @@ func TestConnector_ExecWithReqID(t *testing.T) {
}
}

// @author: xftan
// @date: 2023/10/13 11:13
// @description: test query with reqID
func TestConnector_QueryWithReqID(t *testing.T) {
db := testDatabase(t)
defer db.Close()
Expand Down
6 changes: 6 additions & 0 deletions af/tmq/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ import (
"github.com/taosdata/driver-go/v3/wrapper"
)

// @author: xftan
// @date: 2023/10/13 11:10
// @description: test config
func TestConfig(t *testing.T) {
conf := newConfig()
conf.destroy()
}

// @author: xftan
// @date: 2023/10/13 11:11
// @description: test topic list
func TestList(t *testing.T) {
topicList := wrapper.TMQListNew()
wrapper.TMQListAppend(topicList, "123")
Expand Down
7 changes: 7 additions & 0 deletions af/tmq/consumer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import (
"github.com/taosdata/driver-go/v3/wrapper"
)

// @author: xftan
// @date: 2023/10/13 11:11
// @description: test tmq
func TestTmq(t *testing.T) {
conn, err := wrapper.TaosConnect("", "root", "taosdata", "", 0)
if err != nil {
Expand Down Expand Up @@ -147,6 +150,9 @@ func TestTmq(t *testing.T) {
assert.True(t, haveMessage)
}

// @author: xftan
// @date: 2023/10/13 11:11
// @description: test seek
func TestSeek(t *testing.T) {
conn, err := wrapper.TaosConnect("", "root", "taosdata", "", 0)
if err != nil {
Expand Down Expand Up @@ -191,6 +197,7 @@ func TestSeek(t *testing.T) {
"td.connect.user": "root",
"td.connect.pass": "taosdata",
"td.connect.port": "6030",
"auto.offset.reset": "earliest",
"client.id": "test_tmq_seek",
"enable.auto.commit": "false",
"msg.with.table.name": "true",
Expand Down
15 changes: 15 additions & 0 deletions common/parser/block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import (
"github.com/taosdata/driver-go/v3/wrapper"
)

// @author: xftan
// @date: 2023/10/13 11:13
// @description: test block
func TestReadBlock(t *testing.T) {
conn, err := wrapper.TaosConnect("", "root", "taosdata", "", 0)
if err != nil {
Expand Down Expand Up @@ -170,6 +173,9 @@ func TestReadBlock(t *testing.T) {
}
}

// @author: xftan
// @date: 2023/10/13 11:13
// @description: test block tag
func TestBlockTag(t *testing.T) {
conn, err := wrapper.TaosConnect("", "root", "taosdata", "", 0)
if err != nil {
Expand Down Expand Up @@ -293,6 +299,9 @@ func TestBlockTag(t *testing.T) {
t.Log(len(data[0][1].(string)))
}

// @author: xftan
// @date: 2023/10/13 11:18
// @description: test read row
func TestReadRow(t *testing.T) {
conn, err := wrapper.TaosConnect("", "root", "taosdata", "", 0)
if err != nil {
Expand Down Expand Up @@ -428,6 +437,9 @@ func TestReadRow(t *testing.T) {
assert.Equal(t, []byte(`{"a":1}`), row2[14].([]byte))
}

// @author: xftan
// @date: 2023/10/13 11:18
// @description: test read block with time format
func TestReadBlockWithTimeFormat(t *testing.T) {
conn, err := wrapper.TaosConnect("", "root", "taosdata", "", 0)
if err != nil {
Expand Down Expand Up @@ -561,6 +573,9 @@ func TestReadBlockWithTimeFormat(t *testing.T) {
assert.Equal(t, []byte(`{"a":1}`), row2[14].([]byte))
}

// @author: xftan
// @date: 2023/10/13 11:18
// @description: test parse block
func TestParseBlock(t *testing.T) {
conn, err := wrapper.TaosConnect("", "root", "taosdata", "", 0)
if err != nil {
Expand Down
6 changes: 6 additions & 0 deletions common/reqid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,16 @@ func BenchmarkGetReqIDParallel(b *testing.B) {
})
}

// @author: xftan
// @date: 2023/10/13 11:20
// @description: test get req id
func TestGetReqID(t *testing.T) {
t.Log(GetReqID())
}

// @author: xftan
// @date: 2023/10/13 11:20
// @description: test MurmurHash
func TestMurmurHash(t *testing.T) {
if murmurHash32([]byte("driver-go"), 0) != 3037880692 {
t.Fatal("fail")
Expand Down
3 changes: 3 additions & 0 deletions common/serializer/block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import (
"github.com/taosdata/driver-go/v3/common/param"
)

// @author: xftan
// @date: 2023/10/13 11:19
// @description: test block
func TestSerializeRawBlock(t *testing.T) {
type args struct {
params []*param.Param
Expand Down
6 changes: 6 additions & 0 deletions common/tmq/tmq_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ const dropJson = `{
"tableNameList":["t1", "t2"]
}`

// @author: xftan
// @date: 2023/10/13 11:19
// @description: test json
func TestCreateJson(t *testing.T) {
var obj Meta
err := json.Unmarshal([]byte(createJson), &obj)
Expand All @@ -51,6 +54,9 @@ func TestCreateJson(t *testing.T) {
t.Log(obj)
}

// @author: xftan
// @date: 2023/10/13 11:19
// @description: test drop json
func TestDropJson(t *testing.T) {
var obj Meta
err := json.Unmarshal([]byte(dropJson), &obj)
Expand Down
3 changes: 3 additions & 0 deletions errors/errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ package errors

import "testing"

// @author: xftan
// @date: 2023/10/13 11:20
// @description: test new error
func TestNewError(t *testing.T) {
type args struct {
code int
Expand Down
12 changes: 6 additions & 6 deletions taosRestful/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,33 +245,33 @@ func TestChinese(t *testing.T) {
}
defer db.Close()
defer func() {
_, err = db.Exec("drop database if exists test_chinese_rs")
_, err = db.Exec("drop database if exists test_chinese_rest")
if err != nil {
t.Error(err)
return
}
}()
_, err = db.Exec("create database if not exists test_chinese_rs")
_, err = db.Exec("create database if not exists test_chinese_rest")
if err != nil {
t.Error(err)
return
}
_, err = db.Exec("drop table if exists test_chinese_rs.chinese")
_, err = db.Exec("drop table if exists test_chinese_rest.chinese")
if err != nil {
t.Error(err)
return
}
_, err = db.Exec("create table if not exists test_chinese_rs.chinese(ts timestamp,v nchar(32))")
_, err = db.Exec("create table if not exists test_chinese_rest.chinese(ts timestamp,v nchar(32))")
if err != nil {
t.Error(err)
return
}
_, err = db.Exec(`INSERT INTO test_chinese_rs.chinese (ts, v) VALUES (?, ?)`, "1641010332000", "'阴天'")
_, err = db.Exec(`INSERT INTO test_chinese_rest.chinese (ts, v) VALUES (?, ?)`, "1641010332000", "'阴天'")
if err != nil {
t.Error(err)
return
}
rows, err := db.Query("select * from test_chinese_rs.chinese")
rows, err := db.Query("select * from test_chinese_rest.chinese")
if err != nil {
t.Error(err)
return
Expand Down
3 changes: 3 additions & 0 deletions taosSql/connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import (
"github.com/taosdata/driver-go/v3/common"
)

// @author: xftan
// @date: 2023/10/13 11:21
// @description: test taos connection exec context
func TestTaosConn_ExecContext(t *testing.T) {
ctx := context.WithValue(context.Background(), common.ReqIDKey, common.GetReqID())
db, err := sql.Open("taosSql", dataSourceName)
Expand Down
6 changes: 6 additions & 0 deletions taosSql/statement_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import (
"github.com/stretchr/testify/assert"
)

// @author: xftan
// @date: 2023/10/13 11:22
// @description: test stmt exec
func TestStmtExec(t *testing.T) {
db, err := sql.Open(driverName, dataSourceName)
if err != nil {
Expand Down Expand Up @@ -185,6 +188,9 @@ func TestStmtExec(t *testing.T) {
// assert.Equal(t, 1, count)
//}

// @author: xftan
// @date: 2023/10/13 11:22
// @description: test stmt convert
func TestStmtConvertExec(t *testing.T) {
db, err := sql.Open(driverName, dataSourceName)
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions taosWS/connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import (
"github.com/stretchr/testify/assert"
)

// @author: xftan
// @date: 2023/10/13 11:22
// @description: test format bytes
func Test_formatBytes(t *testing.T) {
type args struct {
bs []byte
Expand Down
18 changes: 18 additions & 0 deletions taosWS/connector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import (
"github.com/taosdata/driver-go/v3/types"
)

// @author: xftan
// @date: 2023/10/13 11:22
// @description: test all type query
func TestAllTypeQuery(t *testing.T) {
rand.Seed(time.Now().UnixNano())
db, err := sql.Open("taosWS", dataSourceName)
Expand Down Expand Up @@ -141,6 +144,9 @@ func TestAllTypeQuery(t *testing.T) {
}
}

// @author: xftan
// @date: 2023/10/13 11:22
// @description: test null value
func TestAllTypeQueryNull(t *testing.T) {
rand.Seed(time.Now().UnixNano())
db, err := sql.Open("taosWS", dataSourceName)
Expand Down Expand Up @@ -257,6 +263,9 @@ func TestAllTypeQueryNull(t *testing.T) {
}
}

// @author: xftan
// @date: 2023/10/13 11:24
// @description: test compression
func TestAllTypeQueryCompression(t *testing.T) {
rand.Seed(time.Now().UnixNano())
db, err := sql.Open("taosWS", dataSourceNameWithCompression)
Expand Down Expand Up @@ -386,6 +395,9 @@ func TestAllTypeQueryCompression(t *testing.T) {
}
}

// @author: xftan
// @date: 2023/10/13 11:24
// @description: test all type query without json
func TestAllTypeQueryWithoutJson(t *testing.T) {
rand.Seed(time.Now().UnixNano())
db, err := sql.Open("taosWS", dataSourceName)
Expand Down Expand Up @@ -512,6 +524,9 @@ func TestAllTypeQueryWithoutJson(t *testing.T) {
}
}

// @author: xftan
// @date: 2023/10/13 11:24
// @description: test all type query with null without json
func TestAllTypeQueryNullWithoutJson(t *testing.T) {
rand.Seed(time.Now().UnixNano())
db, err := sql.Open("taosWS", dataSourceName)
Expand Down Expand Up @@ -624,6 +639,9 @@ func TestAllTypeQueryNullWithoutJson(t *testing.T) {
}
}

// @author: xftan
// @date: 2023/10/13 11:24
// @description: test query
func TestBatch(t *testing.T) {
now := time.Now()
tests := []struct {
Expand Down
Loading

0 comments on commit a3d62aa

Please sign in to comment.