|
@@ -54,7 +54,7 @@ func TestTransaction(t *testing.T) {
|
|
newTableNum := rand.New(rand.NewSource(now.Unix())).Intn(10)
|
|
newTableNum := rand.New(rand.NewSource(now.Unix())).Intn(10)
|
|
|
|
|
|
var count int64
|
|
var count int64
|
|
- resultMap := make(map[string]any)
|
|
+ resultTableRow := client.NewTableRow()
|
|
|
|
|
|
newToolKit(t).
|
|
newToolKit(t).
|
|
autoMigrate([]client.AutoMigrateItem{
|
|
autoMigrate([]client.AutoMigrateItem{
|
|
@@ -69,12 +69,11 @@ func TestTransaction(t *testing.T) {
|
|
TablePrefixWithSchema: tablePrefix,
|
|
TablePrefixWithSchema: tablePrefix,
|
|
Version: "v1",
|
|
Version: "v1",
|
|
KeyColumns: []string{"id"},
|
|
KeyColumns: []string{"id"},
|
|
- TableRow: map[string]any{
|
|
+ TableRow: client.NewTableRow().
|
|
- "id": id,
|
|
+ AddColumnValueString("id", id).
|
|
- "name": name,
|
|
+ AddColumnValueString("name", name).
|
|
- "time": now,
|
|
+ AddColumnValueTime("time", now).
|
|
- "table_num": tableNum,
|
|
+ AddColumnValueInt("table_num", tableNum),
|
|
- },
|
|
|
|
UserID: "test",
|
|
UserID: "test",
|
|
})
|
|
})
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -89,22 +88,21 @@ func TestTransaction(t *testing.T) {
|
|
TablePrefixWithSchema: tablePrefix,
|
|
TablePrefixWithSchema: tablePrefix,
|
|
Version: "v1",
|
|
Version: "v1",
|
|
KeyValues: map[string]string{"id": id},
|
|
KeyValues: map[string]string{"id": id},
|
|
- }, &resultMap).
|
|
+ }, resultTableRow).
|
|
- assertEqual(id, resultMap["id"], "ID不一致").
|
|
+ assertEqual(id, resultTableRow.ColumnValueString("id"), "ID不一致").
|
|
- assertEqual(name, resultMap["name"], "名称不一致").
|
|
+ assertEqual(name, resultTableRow.ColumnValueString("name"), "名称不一致").
|
|
- assertEqual(now.Unix(), resultMap["time"].(time.Time).Unix(), "时间不一致").
|
|
+ assertEqual(now.Unix(), resultTableRow.ColumnValueTime("time").Unix(), "时间不一致").
|
|
- assertEqual(uint64(tableNum), resultMap["table_num"], "表数量不一致").
|
|
+ assertEqual(tableNum, resultTableRow.ColumnValueInt("table_num"), "表数量不一致").
|
|
transaction(func(tx client.Transaction) error {
|
|
transaction(func(tx client.Transaction) error {
|
|
statement, err := tx.UpdateTx(&client.UpdateRequest{
|
|
statement, err := tx.UpdateTx(&client.UpdateRequest{
|
|
TablePrefixWithSchema: tablePrefix,
|
|
TablePrefixWithSchema: tablePrefix,
|
|
Version: "v1",
|
|
Version: "v1",
|
|
KeyValues: map[string]string{"id": id},
|
|
KeyValues: map[string]string{"id": id},
|
|
- NewTableRow: map[string]any{
|
|
+ NewTableRow: client.NewTableRow().
|
|
- "id": id,
|
|
+ AddColumnValueString("id", id).
|
|
- "name": newName,
|
|
+ AddColumnValueString("name", newName).
|
|
- "time": newNow,
|
|
+ AddColumnValueTime("time", newNow).
|
|
- "table_num": newTableNum,
|
|
+ AddColumnValueInt("table_num", newTableNum),
|
|
- },
|
|
|
|
UserID: "test",
|
|
UserID: "test",
|
|
})
|
|
})
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -119,22 +117,21 @@ func TestTransaction(t *testing.T) {
|
|
TablePrefixWithSchema: tablePrefix,
|
|
TablePrefixWithSchema: tablePrefix,
|
|
Version: "v1",
|
|
Version: "v1",
|
|
KeyValues: map[string]string{"id": id},
|
|
KeyValues: map[string]string{"id": id},
|
|
- }, &resultMap).
|
|
+ }, resultTableRow).
|
|
- assertEqual(id, resultMap["id"], "ID不一致").
|
|
+ assertEqual(id, resultTableRow.ColumnValueString("id"), "ID不一致").
|
|
- assertEqual(newName, resultMap["name"], "名称不一致").
|
|
+ assertEqual(newName, resultTableRow.ColumnValueString("name"), "名称不一致").
|
|
- assertEqual(newNow.Unix(), resultMap["time"].(time.Time).Unix(), "时间不一致").
|
|
+ assertEqual(newNow.Unix(), resultTableRow.ColumnValueTime("time").Unix(), "时间不一致").
|
|
- assertEqual(uint64(newTableNum), resultMap["table_num"], "表数量不一致").
|
|
+ assertEqual(newTableNum, resultTableRow.ColumnValueInt("table_num"), "表数量不一致").
|
|
transaction(func(tx client.Transaction) error {
|
|
transaction(func(tx client.Transaction) error {
|
|
statement, err := tx.UpdateTx(&client.UpdateRequest{
|
|
statement, err := tx.UpdateTx(&client.UpdateRequest{
|
|
TablePrefixWithSchema: tablePrefix,
|
|
TablePrefixWithSchema: tablePrefix,
|
|
Version: "v1",
|
|
Version: "v1",
|
|
KeyValues: map[string]string{"id": id},
|
|
KeyValues: map[string]string{"id": id},
|
|
- NewTableRow: map[string]any{
|
|
+ NewTableRow: client.NewTableRow().
|
|
- "id": id,
|
|
+ AddColumnValueString("id", id).
|
|
- "name": name,
|
|
+ AddColumnValueString("name", name).
|
|
- "time": now,
|
|
+ AddColumnValueTime("time", now).
|
|
- "table_num": tableNum,
|
|
+ AddColumnValueInt("table_num", tableNum),
|
|
- },
|
|
|
|
UserID: "test",
|
|
UserID: "test",
|
|
})
|
|
})
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -184,7 +181,7 @@ func TestTransactionBatch(t *testing.T) {
|
|
tableNum2 := rand.New(rand.NewSource(now2.Unix())).Intn(10)
|
|
tableNum2 := rand.New(rand.NewSource(now2.Unix())).Intn(10)
|
|
|
|
|
|
var count int64
|
|
var count int64
|
|
- resultMap := make(map[string]any)
|
|
+ resultTableRow := client.NewTableRow()
|
|
|
|
|
|
newToolKit(t).
|
|
newToolKit(t).
|
|
autoMigrate([]client.AutoMigrateItem{
|
|
autoMigrate([]client.AutoMigrateItem{
|
|
@@ -201,19 +198,17 @@ func TestTransactionBatch(t *testing.T) {
|
|
TablePrefixWithSchema: tablePrefix,
|
|
TablePrefixWithSchema: tablePrefix,
|
|
Version: "v1",
|
|
Version: "v1",
|
|
KeyColumns: []string{"id"},
|
|
KeyColumns: []string{"id"},
|
|
- TableRows: []map[string]any{
|
|
+ TableRows: []*client.TableRow{
|
|
- {
|
|
+ client.NewTableRow().
|
|
- "id": id1,
|
|
+ AddColumnValueString("id", id1).
|
|
- "name": name1,
|
|
+ AddColumnValueString("name", name1).
|
|
- "time": now1,
|
|
+ AddColumnValueTime("time", now1).
|
|
- "table_num": tableNum1,
|
|
+ AddColumnValueInt("table_num", tableNum1),
|
|
- },
|
|
+ client.NewTableRow().
|
|
- {
|
|
+ AddColumnValueString("id", id2).
|
|
- "id": id2,
|
|
+ AddColumnValueString("name", name2).
|
|
- "name": name2,
|
|
+ AddColumnValueTime("time", now2).
|
|
- "time": now2,
|
|
+ AddColumnValueInt("table_num", tableNum2),
|
|
- "table_num": tableNum2,
|
|
|
|
- },
|
|
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
@@ -230,20 +225,20 @@ func TestTransactionBatch(t *testing.T) {
|
|
TablePrefixWithSchema: tablePrefix,
|
|
TablePrefixWithSchema: tablePrefix,
|
|
Version: "v1",
|
|
Version: "v1",
|
|
KeyValues: map[string]string{"id": id1},
|
|
KeyValues: map[string]string{"id": id1},
|
|
- }, &resultMap).
|
|
+ }, resultTableRow).
|
|
- assertEqual(id1, resultMap["id"], "ID不一致").
|
|
+ assertEqual(id1, resultTableRow.ColumnValueString("id"), "ID不一致").
|
|
- assertEqual(name1, resultMap["name"], "名称不一致").
|
|
+ assertEqual(name1, resultTableRow.ColumnValueString("name"), "名称不一致").
|
|
- assertEqual(now1.Unix(), resultMap["time"].(time.Time).Unix(), "时间不一致").
|
|
+ assertEqual(now1.Unix(), resultTableRow.ColumnValueTime("time").Unix(), "时间不一致").
|
|
- assertEqual(uint64(tableNum1), resultMap["table_num"], "表数量不一致").
|
|
+ assertEqual(tableNum1, resultTableRow.ColumnValueInt("table_num"), "表数量不一致").
|
|
queryByKeys(&client.QueryByKeysRequest{
|
|
queryByKeys(&client.QueryByKeysRequest{
|
|
TablePrefixWithSchema: tablePrefix,
|
|
TablePrefixWithSchema: tablePrefix,
|
|
Version: "v1",
|
|
Version: "v1",
|
|
KeyValues: map[string]string{"id": id2},
|
|
KeyValues: map[string]string{"id": id2},
|
|
- }, &resultMap).
|
|
+ }, resultTableRow).
|
|
- assertEqual(id2, resultMap["id"], "ID不一致").
|
|
+ assertEqual(id2, resultTableRow.ColumnValueString("id"), "ID不一致").
|
|
- assertEqual(name2, resultMap["name"], "名称不一致").
|
|
+ assertEqual(name2, resultTableRow.ColumnValueString("name"), "名称不一致").
|
|
- assertEqual(now2.Unix(), resultMap["time"].(time.Time).Unix(), "时间不一致").
|
|
+ assertEqual(now2.Unix(), resultTableRow.ColumnValueTime("time").Unix(), "时间不一致").
|
|
- assertEqual(uint64(tableNum2), resultMap["table_num"], "表数量不一致").
|
|
+ assertEqual(tableNum2, resultTableRow.ColumnValueInt("table_num"), "表数量不一致").
|
|
transaction(func(tx client.Transaction) error {
|
|
transaction(func(tx client.Transaction) error {
|
|
statement, err := tx.DeleteBatchTx(&client.DeleteBatchRequest{
|
|
statement, err := tx.DeleteBatchTx(&client.DeleteBatchRequest{
|
|
Items: []client.DeleteTableRowItem{
|
|
Items: []client.DeleteTableRowItem{
|
|
@@ -295,7 +290,8 @@ func TestInsert(t *testing.T) {
|
|
now := time.Now().Local()
|
|
now := time.Now().Local()
|
|
tableNum := rand.New(rand.NewSource(now.Unix())).Intn(10)
|
|
tableNum := rand.New(rand.NewSource(now.Unix())).Intn(10)
|
|
|
|
|
|
- resultMap := make(map[string]any)
|
|
+ resultTableRow := client.NewTableRow()
|
|
|
|
+ var exist bool
|
|
|
|
|
|
newToolKit(t).
|
|
newToolKit(t).
|
|
autoMigrate([]client.AutoMigrateItem{
|
|
autoMigrate([]client.AutoMigrateItem{
|
|
@@ -309,23 +305,38 @@ func TestInsert(t *testing.T) {
|
|
TablePrefixWithSchema: tablePrefix,
|
|
TablePrefixWithSchema: tablePrefix,
|
|
Version: "v1",
|
|
Version: "v1",
|
|
KeyColumns: []string{"id"},
|
|
KeyColumns: []string{"id"},
|
|
- TableRow: map[string]any{
|
|
+ TableRow: client.NewTableRow().
|
|
- "id": id,
|
|
+ AddColumnValueString("id", id).
|
|
- "name": name,
|
|
+ AddColumnValueString("name", name).
|
|
- "time": now,
|
|
+ AddColumnValueTime("time", now).
|
|
- "table_num": tableNum,
|
|
+ AddColumnValueInt("table_num", tableNum),
|
|
- },
|
|
|
|
UserID: "test",
|
|
UserID: "test",
|
|
}).
|
|
}).
|
|
queryByKeys(&client.QueryByKeysRequest{
|
|
queryByKeys(&client.QueryByKeysRequest{
|
|
TablePrefixWithSchema: tablePrefix,
|
|
TablePrefixWithSchema: tablePrefix,
|
|
Version: "v1",
|
|
Version: "v1",
|
|
KeyValues: map[string]string{"id": id},
|
|
KeyValues: map[string]string{"id": id},
|
|
- }, &resultMap).
|
|
+ }, resultTableRow).
|
|
- assertEqual(id, resultMap["id"], "ID不一致").
|
|
+ assertEqual(id, resultTableRow.ColumnValueString("id"), "ID不一致").
|
|
- assertEqual(name, resultMap["name"], "名称不一致").
|
|
+ assertEqual(name, resultTableRow.ColumnValueString("name"), "名称不一致").
|
|
- assertEqual(now.Unix(), resultMap["time"].(time.Time).Local().Unix(), "时间不一致").
|
|
+ assertEqual(now.Unix(), resultTableRow.ColumnValueTime("time").Unix(), "时间不一致").
|
|
- assertEqual(uint64(tableNum), resultMap["table_num"], "表数量不一致")
|
|
+ assertEqual(tableNum, resultTableRow.ColumnValueInt("table_num"), "表数量不一致").
|
|
|
|
+ checkExistWhere(&client.CountWhereRequest{
|
|
|
|
+ TablePrefixWithSchema: tablePrefix,
|
|
|
|
+ Version: "v1",
|
|
|
|
+ Where: map[string][]any{
|
|
|
|
+ "id = ?": {id},
|
|
|
|
+ },
|
|
|
|
+ }, &exist).
|
|
|
|
+ assertEqual(true, exist, "存在状态不一致").
|
|
|
|
+ commonCheckExist(&client.CommonCountRequest{
|
|
|
|
+ TablePrefixWithSchema: tablePrefix,
|
|
|
|
+ Version: "v1",
|
|
|
|
+ Where: map[string][]any{
|
|
|
|
+ "id = ? AND name = ? AND table_num = ?": {id, name, tableNum},
|
|
|
|
+ },
|
|
|
|
+ }, &exist).
|
|
|
|
+ assertEqual(true, exist, "存在状态不一致")
|
|
}
|
|
}
|
|
|
|
|
|
func TestInsertBatch(t *testing.T) {
|
|
func TestInsertBatch(t *testing.T) {
|
|
@@ -344,7 +355,7 @@ func TestInsertBatch(t *testing.T) {
|
|
now2 := time.Now().Local()
|
|
now2 := time.Now().Local()
|
|
tableNum2 := rand.New(rand.NewSource(now2.Unix())).Intn(10)
|
|
tableNum2 := rand.New(rand.NewSource(now2.Unix())).Intn(10)
|
|
|
|
|
|
- resultsMap := make([]map[string]any, 0)
|
|
+ resultTableRows := make([]client.TableRow, 0)
|
|
var totalCount int64
|
|
var totalCount int64
|
|
|
|
|
|
newToolKit(t).
|
|
newToolKit(t).
|
|
@@ -361,19 +372,17 @@ func TestInsertBatch(t *testing.T) {
|
|
TablePrefixWithSchema: tablePrefix,
|
|
TablePrefixWithSchema: tablePrefix,
|
|
Version: "v1",
|
|
Version: "v1",
|
|
KeyColumns: []string{"id"},
|
|
KeyColumns: []string{"id"},
|
|
- TableRows: []map[string]any{
|
|
+ TableRows: []*client.TableRow{
|
|
- {
|
|
+ client.NewTableRow().
|
|
- "id": id1,
|
|
+ AddColumnValueString("id", id1).
|
|
- "name": name1,
|
|
+ AddColumnValueString("name", name1).
|
|
- "time": now1,
|
|
+ AddColumnValueTime("time", now1).
|
|
- "table_num": tableNum1,
|
|
+ AddColumnValueInt("table_num", tableNum1),
|
|
- },
|
|
+ client.NewTableRow().
|
|
- {
|
|
+ AddColumnValueString("id", id2).
|
|
- "id": id2,
|
|
+ AddColumnValueString("name", name2).
|
|
- "name": name2,
|
|
+ AddColumnValueTime("time", now2).
|
|
- "time": now2,
|
|
+ AddColumnValueInt("table_num", tableNum2),
|
|
- "table_num": tableNum2,
|
|
|
|
- },
|
|
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
@@ -386,12 +395,12 @@ func TestInsertBatch(t *testing.T) {
|
|
},
|
|
},
|
|
PageNo: 1,
|
|
PageNo: 1,
|
|
PageSize: 1,
|
|
PageSize: 1,
|
|
- }, &resultsMap, &totalCount).
|
|
+ }, &resultTableRows, &totalCount).
|
|
assertEqual(1, int(totalCount), "总数不一致").
|
|
assertEqual(1, int(totalCount), "总数不一致").
|
|
- assertEqual(id1, resultsMap[0]["id"], "ID不一致").
|
|
+ assertEqual(id1, resultTableRows[0].ColumnValueString("id"), "ID不一致").
|
|
- assertEqual(name1, resultsMap[0]["name"], "名称不一致").
|
|
+ assertEqual(name1, resultTableRows[0].ColumnValueString("name"), "名称不一致").
|
|
- assertEqual(now1.Unix(), resultsMap[0]["time"].(time.Time).Local().Unix(), "时间不一致").
|
|
+ assertEqual(now1.Unix(), resultTableRows[0].ColumnValueTime("time").Unix(), "时间不一致").
|
|
- assertEqual(uint64(tableNum1), resultsMap[0]["table_num"], "表数量不一致").
|
|
+ assertEqual(tableNum1, resultTableRows[0].ColumnValueInt("table_num"), "表数量不一致").
|
|
commonQuery(&client.CommonQueryRequest{
|
|
commonQuery(&client.CommonQueryRequest{
|
|
TablePrefixWithSchema: tablePrefix,
|
|
TablePrefixWithSchema: tablePrefix,
|
|
Version: "v1",
|
|
Version: "v1",
|
|
@@ -400,12 +409,12 @@ func TestInsertBatch(t *testing.T) {
|
|
},
|
|
},
|
|
PageNo: 1,
|
|
PageNo: 1,
|
|
PageSize: 1,
|
|
PageSize: 1,
|
|
- }, &resultsMap, &totalCount).
|
|
+ }, &resultTableRows, &totalCount).
|
|
assertEqual(1, int(totalCount), "总数不一致").
|
|
assertEqual(1, int(totalCount), "总数不一致").
|
|
- assertEqual(id2, resultsMap[0]["id"], "ID不一致").
|
|
+ assertEqual(id2, resultTableRows[0].ColumnValueString("id"), "ID不一致").
|
|
- assertEqual(name2, resultsMap[0]["name"], "名称不一致").
|
|
+ assertEqual(name2, resultTableRows[0].ColumnValueString("name"), "名称不一致").
|
|
- assertEqual(now2.Unix(), resultsMap[0]["time"].(time.Time).Local().Unix(), "时间不一致").
|
|
+ assertEqual(now2.Unix(), resultTableRows[0].ColumnValueTime("time").Unix(), "时间不一致").
|
|
- assertEqual(uint64(tableNum2), resultsMap[0]["table_num"], "表数量不一致").
|
|
+ assertEqual(tableNum2, resultTableRows[0].ColumnValueInt("table_num"), "表数量不一致").
|
|
queryOnlyByWhereAndOrderBy(&client.QueryByWhereAndOrderByRequest{
|
|
queryOnlyByWhereAndOrderBy(&client.QueryByWhereAndOrderByRequest{
|
|
TablePrefixWithSchema: tablePrefix,
|
|
TablePrefixWithSchema: tablePrefix,
|
|
Version: "v1",
|
|
Version: "v1",
|
|
@@ -414,11 +423,11 @@ func TestInsertBatch(t *testing.T) {
|
|
},
|
|
},
|
|
PageNo: 1,
|
|
PageNo: 1,
|
|
PageSize: 1,
|
|
PageSize: 1,
|
|
- }, &resultsMap).
|
|
+ }, &resultTableRows).
|
|
- assertEqual(id1, resultsMap[0]["id"], "ID不一致").
|
|
+ assertEqual(id1, resultTableRows[0].ColumnValueString("id"), "ID不一致").
|
|
- assertEqual(name1, resultsMap[0]["name"], "名称不一致").
|
|
+ assertEqual(name1, resultTableRows[0].ColumnValueString("name"), "名称不一致").
|
|
- assertEqual(now1.Unix(), resultsMap[0]["time"].(time.Time).Local().Unix(), "时间不一致").
|
|
+ assertEqual(now1.Unix(), resultTableRows[0].ColumnValueTime("time").Unix(), "时间不一致").
|
|
- assertEqual(uint64(tableNum1), resultsMap[0]["table_num"], "表数量不一致").
|
|
+ assertEqual(tableNum1, resultTableRows[0].ColumnValueInt("table_num"), "表数量不一致").
|
|
commonQueryOnly(&client.CommonQueryRequest{
|
|
commonQueryOnly(&client.CommonQueryRequest{
|
|
TablePrefixWithSchema: tablePrefix,
|
|
TablePrefixWithSchema: tablePrefix,
|
|
Version: "v1",
|
|
Version: "v1",
|
|
@@ -427,11 +436,11 @@ func TestInsertBatch(t *testing.T) {
|
|
},
|
|
},
|
|
PageNo: 1,
|
|
PageNo: 1,
|
|
PageSize: 1,
|
|
PageSize: 1,
|
|
- }, &resultsMap).
|
|
+ }, &resultTableRows).
|
|
- assertEqual(id2, resultsMap[0]["id"], "ID不一致").
|
|
+ assertEqual(id2, resultTableRows[0].ColumnValueString("id"), "ID不一致").
|
|
- assertEqual(name2, resultsMap[0]["name"], "名称不一致").
|
|
+ assertEqual(name2, resultTableRows[0].ColumnValueString("name"), "名称不一致").
|
|
- assertEqual(now2.Unix(), resultsMap[0]["time"].(time.Time).Local().Unix(), "时间不一致").
|
|
+ assertEqual(now2.Unix(), resultTableRows[0].ColumnValueTime("time").Unix(), "时间不一致").
|
|
- assertEqual(uint64(tableNum2), resultsMap[0]["table_num"], "表数量不一致")
|
|
+ assertEqual(tableNum2, resultTableRows[0].ColumnValueInt("table_num"), "表数量不一致")
|
|
}
|
|
}
|
|
|
|
|
|
func TestUpdate(t *testing.T) {
|
|
func TestUpdate(t *testing.T) {
|
|
@@ -448,7 +457,7 @@ func TestUpdate(t *testing.T) {
|
|
newNow := time.Now().Local()
|
|
newNow := time.Now().Local()
|
|
newTableNum := rand.New(rand.NewSource(now.Unix())).Intn(10)
|
|
newTableNum := rand.New(rand.NewSource(now.Unix())).Intn(10)
|
|
|
|
|
|
- resultMap := make(map[string]any)
|
|
+ resultTableRow := client.NewTableRow()
|
|
|
|
|
|
newToolKit(t).
|
|
newToolKit(t).
|
|
autoMigrate([]client.AutoMigrateItem{
|
|
autoMigrate([]client.AutoMigrateItem{
|
|
@@ -462,35 +471,33 @@ func TestUpdate(t *testing.T) {
|
|
TablePrefixWithSchema: tablePrefix,
|
|
TablePrefixWithSchema: tablePrefix,
|
|
Version: "v1",
|
|
Version: "v1",
|
|
KeyColumns: []string{"id"},
|
|
KeyColumns: []string{"id"},
|
|
- TableRow: map[string]any{
|
|
+ TableRow: client.NewTableRow().
|
|
- "id": id,
|
|
+ AddColumnValueString("id", id).
|
|
- "name": name,
|
|
+ AddColumnValueString("name", name).
|
|
- "time": now,
|
|
+ AddColumnValueTime("time", now).
|
|
- "table_num": tableNum,
|
|
+ AddColumnValueInt("table_num", tableNum),
|
|
- },
|
|
|
|
UserID: "test",
|
|
UserID: "test",
|
|
}).
|
|
}).
|
|
update(&client.UpdateRequest{
|
|
update(&client.UpdateRequest{
|
|
TablePrefixWithSchema: tablePrefix,
|
|
TablePrefixWithSchema: tablePrefix,
|
|
Version: "v1",
|
|
Version: "v1",
|
|
KeyValues: map[string]string{"id": id},
|
|
KeyValues: map[string]string{"id": id},
|
|
- NewTableRow: map[string]any{
|
|
+ NewTableRow: client.NewTableRow().
|
|
- "id": id,
|
|
+ AddColumnValueString("id", id).
|
|
- "name": newName,
|
|
+ AddColumnValueString("name", newName).
|
|
- "time": newNow,
|
|
+ AddColumnValueTime("time", newNow).
|
|
- "table_num": newTableNum,
|
|
+ AddColumnValueInt("table_num", newTableNum),
|
|
- },
|
|
|
|
UserID: "test",
|
|
UserID: "test",
|
|
}).
|
|
}).
|
|
queryByKeys(&client.QueryByKeysRequest{
|
|
queryByKeys(&client.QueryByKeysRequest{
|
|
TablePrefixWithSchema: tablePrefix,
|
|
TablePrefixWithSchema: tablePrefix,
|
|
Version: "v1",
|
|
Version: "v1",
|
|
KeyValues: map[string]string{"id": id},
|
|
KeyValues: map[string]string{"id": id},
|
|
- }, &resultMap).
|
|
+ }, resultTableRow).
|
|
- assertEqual(id, resultMap["id"], "ID不一致").
|
|
+ assertEqual(id, resultTableRow.ColumnValueString("id"), "ID不一致").
|
|
- assertEqual(newName, resultMap["name"], "名称不一致").
|
|
+ assertEqual(newName, resultTableRow.ColumnValueString("name"), "名称不一致").
|
|
- assertEqual(newNow.Unix(), resultMap["time"].(time.Time).Local().Unix(), "时间不一致").
|
|
+ assertEqual(newNow.Unix(), resultTableRow.ColumnValueTime("time").Unix(), "时间不一致").
|
|
- assertEqual(uint64(newTableNum), resultMap["table_num"], "表数量不一致")
|
|
+ assertEqual(newTableNum, resultTableRow.ColumnValueInt("table_num"), "表数量不一致")
|
|
}
|
|
}
|
|
|
|
|
|
func TestDelete(t *testing.T) {
|
|
func TestDelete(t *testing.T) {
|
|
@@ -518,12 +525,11 @@ func TestDelete(t *testing.T) {
|
|
TablePrefixWithSchema: tablePrefix,
|
|
TablePrefixWithSchema: tablePrefix,
|
|
Version: "v1",
|
|
Version: "v1",
|
|
KeyColumns: []string{"id"},
|
|
KeyColumns: []string{"id"},
|
|
- TableRow: map[string]any{
|
|
+ TableRow: client.NewTableRow().
|
|
- "id": id,
|
|
+ AddColumnValueString("id", id).
|
|
- "name": name,
|
|
+ AddColumnValueString("name", name).
|
|
- "time": now,
|
|
+ AddColumnValueTime("time", now).
|
|
- "table_num": tableNum,
|
|
+ AddColumnValueInt("table_num", tableNum),
|
|
- },
|
|
|
|
UserID: "test",
|
|
UserID: "test",
|
|
}).
|
|
}).
|
|
delete(&client.DeleteRequest{
|
|
delete(&client.DeleteRequest{
|
|
@@ -574,19 +580,17 @@ func TestDeleteBatch(t *testing.T) {
|
|
TablePrefixWithSchema: tablePrefix,
|
|
TablePrefixWithSchema: tablePrefix,
|
|
Version: "v1",
|
|
Version: "v1",
|
|
KeyColumns: []string{"id"},
|
|
KeyColumns: []string{"id"},
|
|
- TableRows: []map[string]any{
|
|
+ TableRows: []*client.TableRow{
|
|
- {
|
|
+ client.NewTableRow().
|
|
- "id": id1,
|
|
+ AddColumnValueString("id", id1).
|
|
- "name": name1,
|
|
+ AddColumnValueString("name", name1).
|
|
- "time": now1,
|
|
+ AddColumnValueTime("time", now1).
|
|
- "table_num": tableNum1,
|
|
+ AddColumnValueInt("table_num", tableNum1),
|
|
- },
|
|
+ client.NewTableRow().
|
|
- {
|
|
+ AddColumnValueString("id", id2).
|
|
- "id": id2,
|
|
+ AddColumnValueString("name", name2).
|
|
- "name": name2,
|
|
+ AddColumnValueTime("time", now2).
|
|
- "time": now2,
|
|
+ AddColumnValueInt("table_num", tableNum2),
|
|
- "table_num": tableNum2,
|
|
|
|
- },
|
|
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
@@ -622,7 +626,7 @@ func TestReply(t *testing.T) {
|
|
now := time.Now().Local()
|
|
now := time.Now().Local()
|
|
tableNum := rand.New(rand.NewSource(now.Unix())).Intn(10)
|
|
tableNum := rand.New(rand.NewSource(now.Unix())).Intn(10)
|
|
|
|
|
|
- resultMap := make(map[string]any)
|
|
+ resultTableRow := client.NewTableRow()
|
|
|
|
|
|
newToolKit(t).
|
|
newToolKit(t).
|
|
autoMigrate([]client.AutoMigrateItem{
|
|
autoMigrate([]client.AutoMigrateItem{
|
|
@@ -636,12 +640,11 @@ func TestReply(t *testing.T) {
|
|
TablePrefixWithSchema: tablePrefix,
|
|
TablePrefixWithSchema: tablePrefix,
|
|
Version: "v1",
|
|
Version: "v1",
|
|
KeyColumns: []string{"id"},
|
|
KeyColumns: []string{"id"},
|
|
- TableRow: map[string]any{
|
|
+ TableRow: client.NewTableRow().
|
|
- "id": id,
|
|
+ AddColumnValueString("id", id).
|
|
- "name": name,
|
|
+ AddColumnValueString("name", name).
|
|
- "time": now,
|
|
+ AddColumnValueTime("time", now).
|
|
- "table_num": tableNum,
|
|
+ AddColumnValueInt("table_num", tableNum),
|
|
- },
|
|
|
|
UserID: "test",
|
|
UserID: "test",
|
|
}).
|
|
}).
|
|
reply(&client.ReplayRequest{
|
|
reply(&client.ReplayRequest{
|
|
@@ -654,11 +657,11 @@ func TestReply(t *testing.T) {
|
|
TablePrefixWithSchema: tablePrefix,
|
|
TablePrefixWithSchema: tablePrefix,
|
|
Version: "v1",
|
|
Version: "v1",
|
|
KeyValues: map[string]string{"id": id},
|
|
KeyValues: map[string]string{"id": id},
|
|
- }, &resultMap).
|
|
+ }, resultTableRow).
|
|
- assertEqual(id, resultMap["id"], "ID不一致").
|
|
+ assertEqual(id, resultTableRow.ColumnValueString("id"), "ID不一致").
|
|
- assertEqual(name, resultMap["name"], "名称不一致").
|
|
+ assertEqual(name, resultTableRow.ColumnValueString("name"), "名称不一致").
|
|
- assertEqual(now.Unix(), resultMap["time"].(time.Time).Local().Unix(), "时间不一致").
|
|
+ assertEqual(now.Unix(), resultTableRow.ColumnValueTime("time").Unix(), "时间不一致").
|
|
- assertEqual(uint64(tableNum), resultMap["table_num"], "表数量不一致")
|
|
+ assertEqual(tableNum, resultTableRow.ColumnValueInt("table_num"), "表数量不一致")
|
|
}
|
|
}
|
|
|
|
|
|
func TestEventQuery(t *testing.T) {
|
|
func TestEventQuery(t *testing.T) {
|
|
@@ -675,6 +678,7 @@ func TestEventQuery(t *testing.T) {
|
|
newNow := time.Now().Local()
|
|
newNow := time.Now().Local()
|
|
newTableNum := rand.New(rand.NewSource(now.Unix())).Intn(10)
|
|
newTableNum := rand.New(rand.NewSource(now.Unix())).Intn(10)
|
|
|
|
|
|
|
|
+ var exist bool
|
|
var totalCount int64
|
|
var totalCount int64
|
|
eventInfos := make([]client.EventInfo, 0)
|
|
eventInfos := make([]client.EventInfo, 0)
|
|
|
|
|
|
@@ -690,24 +694,37 @@ func TestEventQuery(t *testing.T) {
|
|
TablePrefixWithSchema: tablePrefix,
|
|
TablePrefixWithSchema: tablePrefix,
|
|
Version: "v1",
|
|
Version: "v1",
|
|
KeyColumns: []string{"id"},
|
|
KeyColumns: []string{"id"},
|
|
- TableRow: map[string]any{
|
|
+ TableRow: client.NewTableRow().
|
|
- "id": id,
|
|
+ AddColumnValueString("id", id).
|
|
- "name": name,
|
|
+ AddColumnValueString("name", name).
|
|
- "time": now,
|
|
+ AddColumnValueTime("time", now).
|
|
- "table_num": tableNum,
|
|
+ AddColumnValueInt("table_num", tableNum),
|
|
- },
|
|
|
|
UserID: "test",
|
|
UserID: "test",
|
|
}).
|
|
}).
|
|
|
|
+ checkEventExistByKeys(&client.CountEventByKeysRequest{
|
|
|
|
+ TablePrefixWithSchema: tablePrefix,
|
|
|
|
+ KeyValues: []string{id},
|
|
|
|
+ }, &exist).
|
|
|
|
+ assertEqual(true, exist, "存在状态不一致").
|
|
|
|
+ commonCheckEventExist(&client.CommonCountEventRequest{
|
|
|
|
+ TablePrefixWithSchema: tablePrefix,
|
|
|
|
+ KeyValues: []string{id},
|
|
|
|
+ Version: "v1",
|
|
|
|
+ Operation: "create",
|
|
|
|
+ CreatorID: "test",
|
|
|
|
+ StartCreatedTime: now.Format(time.DateTime),
|
|
|
|
+ EndCreatedTime: now.Add(time.Second).Format(time.DateTime),
|
|
|
|
+ }, &exist).
|
|
|
|
+ assertEqual(true, exist, "存在状态不一致").
|
|
update(&client.UpdateRequest{
|
|
update(&client.UpdateRequest{
|
|
TablePrefixWithSchema: tablePrefix,
|
|
TablePrefixWithSchema: tablePrefix,
|
|
Version: "v1",
|
|
Version: "v1",
|
|
KeyValues: map[string]string{"id": id},
|
|
KeyValues: map[string]string{"id": id},
|
|
- NewTableRow: map[string]any{
|
|
+ NewTableRow: client.NewTableRow().
|
|
- "id": id,
|
|
+ AddColumnValueString("id", id).
|
|
- "name": newName,
|
|
+ AddColumnValueString("name", newName).
|
|
- "time": newNow,
|
|
+ AddColumnValueTime("time", newNow).
|
|
- "table_num": newTableNum,
|
|
+ AddColumnValueInt("table_num", newTableNum),
|
|
- },
|
|
|
|
UserID: "test",
|
|
UserID: "test",
|
|
}).
|
|
}).
|
|
countEventByKeys(&client.CountEventByKeysRequest{
|
|
countEventByKeys(&client.CountEventByKeysRequest{
|
|
@@ -881,6 +898,21 @@ func TestEventQuery(t *testing.T) {
|
|
KeyValues: map[string]string{"id": id},
|
|
KeyValues: map[string]string{"id": id},
|
|
UserID: "test",
|
|
UserID: "test",
|
|
}).
|
|
}).
|
|
|
|
+ checkEventHistoryExistByKeys(&client.CountEventByKeysRequest{
|
|
|
|
+ TablePrefixWithSchema: tablePrefix,
|
|
|
|
+ KeyValues: []string{id},
|
|
|
|
+ }, &exist).
|
|
|
|
+ assertEqual(true, exist, "存在状态不一致").
|
|
|
|
+ commonCheckEventHistoryExist(&client.CommonCountEventRequest{
|
|
|
|
+ TablePrefixWithSchema: tablePrefix,
|
|
|
|
+ KeyValues: []string{id},
|
|
|
|
+ Version: "v1",
|
|
|
|
+ Operation: "create",
|
|
|
|
+ CreatorID: "test",
|
|
|
|
+ StartCreatedTime: now.Format(time.DateTime),
|
|
|
|
+ EndCreatedTime: now.Add(time.Second).Format(time.DateTime),
|
|
|
|
+ }, &exist).
|
|
|
|
+ assertEqual(true, exist, "存在状态不一致").
|
|
countEventHistoryByKeys(&client.CountEventByKeysRequest{
|
|
countEventHistoryByKeys(&client.CountEventByKeysRequest{
|
|
TablePrefixWithSchema: tablePrefix,
|
|
TablePrefixWithSchema: tablePrefix,
|
|
KeyValues: []string{id},
|
|
KeyValues: []string{id},
|