package instance import ( "fmt" "git.sxidc.com/service-supports/dps-sdk/client" uuid "github.com/satori/go.uuid" "math/rand" "strings" "testing" "time" ) func getUUID() string { return uuid.NewV4().String() } func simpleUUID() string { return strings.ReplaceAll(getUUID(), "-", "") } const ( noEvent = false ) var tableModelDescribe = map[string]string{ "ID": "gorm:\"primary_key;type:varchar(32);comment:id;\"", "Name": "gorm:\"not null;type:varchar(128);comment:数据库名称;\"", "Time": "gorm:\"not null;type:timestamp with time zone;comment:数据库时间;\"", "TableNum": "gorm:\"not null;type:integer;comment:数据库表数量;\"", } func TestAutoMigrate(t *testing.T) { initClient(t, "localhost:30170", "ee2d7dabe56646ce835d80873348ee0e") defer destroyClient(t, "ee2d7dabe56646ce835d80873348ee0e") newToolKit(t). autoMigrate([]client.AutoMigrateItem{ { TablePrefixWithSchema: "test." + simpleUUID()[0:8], Version: "v1", TableModelDescribe: tableModelDescribe, NoEvent: noEvent, }, }) } func TestTransaction(t *testing.T) { initClient(t, "localhost:30170", "ee2d7dabe56646ce835d80873348ee0e") defer destroyClient(t, "ee2d7dabe56646ce835d80873348ee0e") tablePrefix := "test." + simpleUUID()[0:8] id := simpleUUID() name := simpleUUID() now := time.Now().Local() tableNum := rand.New(rand.NewSource(now.UnixMicro())).Intn(10) newName := simpleUUID() newNow := time.Now().Local() newTableNum := rand.New(rand.NewSource(now.UnixMicro())).Intn(10) var count int64 resultTableRow := client.NewTableRow() newToolKit(t). autoMigrate([]client.AutoMigrateItem{ { TablePrefixWithSchema: tablePrefix, Version: "v1", TableModelDescribe: tableModelDescribe, NoEvent: noEvent, }, }). transaction(func(tx client.Transaction) error { statement, err := tx.InsertTx(&client.InsertRequest{ TablePrefixWithSchema: tablePrefix, Version: "v1", KeyColumns: []string{"id"}, TableRow: client.NewTableRow(). AddColumnValueString("id", id). AddColumnValueString("name", name). AddColumnValueTime("time", now). AddColumnValueInt("table_num", tableNum), UserID: "test", }) if err != nil { return err } fmt.Println(statement) return nil }). queryByKeys(&client.QueryByKeysRequest{ TablePrefixWithSchema: tablePrefix, Version: "v1", KeyValues: client.NewKeyValue().Add("id", id), }, resultTableRow). assertEqual(id, resultTableRow.ColumnValueString("id"), "ID不一致"). assertEqual(name, resultTableRow.ColumnValueString("name"), "名称不一致"). assertEqual(now.UnixMicro(), resultTableRow.ColumnValueTime("time").UnixMicro(), "时间不一致"). assertEqual(tableNum, resultTableRow.ColumnValueInt("table_num"), "表数量不一致"). transaction(func(tx client.Transaction) error { statement, err := tx.UpdateTx(&client.UpdateRequest{ TablePrefixWithSchema: tablePrefix, Version: "v1", KeyValues: client.NewKeyValue().Add("id", id), NewTableRow: client.NewTableRow(). AddColumnValueString("id", id). AddColumnValueString("name", newName). AddColumnValueTime("time", newNow). AddColumnValueInt("table_num", newTableNum), UserID: "test", }) if err != nil { return err } fmt.Println(statement) return nil }). queryByKeys(&client.QueryByKeysRequest{ TablePrefixWithSchema: tablePrefix, Version: "v1", KeyValues: client.NewKeyValue().Add("id", id), }, resultTableRow). assertEqual(id, resultTableRow.ColumnValueString("id"), "ID不一致"). assertEqual(newName, resultTableRow.ColumnValueString("name"), "名称不一致"). assertEqual(newNow.UnixMicro(), resultTableRow.ColumnValueTime("time").UnixMicro(), "时间不一致"). assertEqual(newTableNum, resultTableRow.ColumnValueInt("table_num"), "表数量不一致"). transaction(func(tx client.Transaction) error { statement, err := tx.UpdateTx(&client.UpdateRequest{ TablePrefixWithSchema: tablePrefix, Version: "v1", KeyValues: client.NewKeyValue().Add("id", id), NewTableRow: client.NewTableRow(). AddColumnValueString("id", id). AddColumnValueString("name", name). AddColumnValueTime("time", now). AddColumnValueInt("table_num", tableNum), UserID: "test", }) if err != nil { return err } fmt.Println(statement) statement, err = tx.DeleteTx(&client.DeleteRequest{ TablePrefixWithSchema: tablePrefix, Version: "v1", KeyValues: client.NewKeyValue().Add("id", id), UserID: "test", }) if err != nil { return err } fmt.Println(statement) return nil }). countWhere(&client.CountWhereRequest{ TablePrefixWithSchema: tablePrefix, Version: "v1", Where: client.NewClause().Equal("id", id), }, &count). assertEqual(int64(0), count, "数量不一致"). insert(&client.InsertRequest{ TablePrefixWithSchema: tablePrefix, Version: "v1", KeyColumns: []string{"id"}, TableRow: client.NewTableRow(). AddColumnValueString("id", id). AddColumnValueString("name", name). AddColumnValueTime("time", now). AddColumnValueInt("table_num", tableNum), UserID: "test", }). transaction(func(tx client.Transaction) error { statement, err := tx.DeleteWhereTx(&client.DeleteWhereRequest{ TablePrefixWithSchema: tablePrefix, Version: "v1", KeyColumns: []string{"id"}, Where: client.NewClause().Equal("name", name), UserID: "test", }) if err != nil { return err } fmt.Println(statement) return nil }). countWhere(&client.CountWhereRequest{ TablePrefixWithSchema: tablePrefix, Version: "v1", Where: client.NewClause().Equal("id", id), }, &count). assertEqual(int64(0), count, "数量不一致") } func TestTransactionBatch(t *testing.T) { initClient(t, "localhost:30170", "ee2d7dabe56646ce835d80873348ee0e") defer destroyClient(t, "ee2d7dabe56646ce835d80873348ee0e") tablePrefix := "test." + simpleUUID()[0:8] id1 := simpleUUID() name1 := simpleUUID() now1 := time.Now().Local() tableNum1 := rand.New(rand.NewSource(now1.UnixMicro())).Intn(10) id2 := simpleUUID() name2 := simpleUUID() now2 := time.Now().Local() tableNum2 := rand.New(rand.NewSource(now2.UnixMicro())).Intn(10) newName := simpleUUID() newNow := time.Now().Local() newTableNum := rand.New(rand.NewSource(newNow.UnixMicro())).Intn(10) var count int64 resultTableRow := client.NewTableRow() newToolKit(t). autoMigrate([]client.AutoMigrateItem{ { TablePrefixWithSchema: tablePrefix, Version: "v1", TableModelDescribe: tableModelDescribe, NoEvent: noEvent, }, }). transaction(func(tx client.Transaction) error { statement, err := tx.InsertBatchTx(&client.InsertBatchRequest{ Items: []client.InsertTableRowItem{ { TablePrefixWithSchema: tablePrefix, Version: "v1", KeyColumns: []string{"id"}, TableRows: []*client.TableRow{ client.NewTableRow(). AddColumnValueString("id", id1). AddColumnValueString("name", name1). AddColumnValueTime("time", now1). AddColumnValueInt("table_num", tableNum1), client.NewTableRow(). AddColumnValueString("id", id2). AddColumnValueString("name", name2). AddColumnValueTime("time", now2). AddColumnValueInt("table_num", tableNum2), }, }, }, }) if err != nil { return err } fmt.Println(statement) return nil }). queryByKeys(&client.QueryByKeysRequest{ TablePrefixWithSchema: tablePrefix, Version: "v1", KeyValues: client.NewKeyValue().Add("id", id1), }, resultTableRow). assertEqual(id1, resultTableRow.ColumnValueString("id"), "ID不一致"). assertEqual(name1, resultTableRow.ColumnValueString("name"), "名称不一致"). assertEqual(now1.UnixMicro(), resultTableRow.ColumnValueTime("time").UnixMicro(), "时间不一致"). assertEqual(tableNum1, resultTableRow.ColumnValueInt("table_num"), "表数量不一致"). queryByKeys(&client.QueryByKeysRequest{ TablePrefixWithSchema: tablePrefix, Version: "v1", KeyValues: client.NewKeyValue().Add("id", id2), }, resultTableRow). assertEqual(id2, resultTableRow.ColumnValueString("id"), "ID不一致"). assertEqual(name2, resultTableRow.ColumnValueString("name"), "名称不一致"). assertEqual(now2.UnixMicro(), resultTableRow.ColumnValueTime("time").UnixMicro(), "时间不一致"). assertEqual(tableNum2, resultTableRow.ColumnValueInt("table_num"), "表数量不一致"). transaction(func(tx client.Transaction) error { statement, err := tx.UpdateWhereTx(&client.UpdateWhereRequest{ TablePrefixWithSchema: tablePrefix, Version: "v1", KeyColumns: []string{"id"}, Where: client.NewClause().In("id", []string{id1, id2}), NewTableRow: client.NewTableRow(). AddColumnValueString("name", newName). AddColumnValueTime("time", newNow). AddColumnValueInt("table_num", newTableNum), UserID: "test", }) if err != nil { return err } fmt.Println(statement) return nil }). queryByKeys(&client.QueryByKeysRequest{ TablePrefixWithSchema: tablePrefix, Version: "v1", KeyValues: client.NewKeyValue().Add("id", id1), }, resultTableRow). assertEqual(id1, resultTableRow.ColumnValueString("id"), "ID不一致"). assertEqual(newName, resultTableRow.ColumnValueString("name"), "名称不一致"). assertEqual(newNow.UnixMicro(), resultTableRow.ColumnValueTime("time").UnixMicro(), "时间不一致"). assertEqual(newTableNum, resultTableRow.ColumnValueInt("table_num"), "表数量不一致"). queryByKeys(&client.QueryByKeysRequest{ TablePrefixWithSchema: tablePrefix, Version: "v1", KeyValues: client.NewKeyValue().Add("id", id2), }, resultTableRow). assertEqual(id2, resultTableRow.ColumnValueString("id"), "ID不一致"). assertEqual(newName, resultTableRow.ColumnValueString("name"), "名称不一致"). assertEqual(newNow.UnixMicro(), resultTableRow.ColumnValueTime("time").UnixMicro(), "时间不一致"). assertEqual(newTableNum, resultTableRow.ColumnValueInt("table_num"), "表数量不一致"). transaction(func(tx client.Transaction) error { statement, err := tx.DeleteWhereTx(&client.DeleteWhereRequest{ TablePrefixWithSchema: tablePrefix, Version: "v1", KeyColumns: []string{"id"}, Where: client.NewClause().In("id", []string{id1, id2}), UserID: "test", }) if err != nil { return err } fmt.Println(statement) return nil }). countWhere(&client.CountWhereRequest{ TablePrefixWithSchema: tablePrefix, Version: "v1", Where: client.NewClause().Equal("id", id1), }, &count). assertEqual(int64(0), count, "数量不一致"). countWhere(&client.CountWhereRequest{ TablePrefixWithSchema: tablePrefix, Version: "v1", Where: client.NewClause().Equal("id", id2), }, &count). assertEqual(int64(0), count, "数量不一致") } func TestInsert(t *testing.T) { initClient(t, "localhost:30170", "ee2d7dabe56646ce835d80873348ee0e") defer destroyClient(t, "ee2d7dabe56646ce835d80873348ee0e") tablePrefix := "test." + simpleUUID()[0:8] id := simpleUUID() name := simpleUUID() now := time.Now().Local() tableNum := rand.New(rand.NewSource(now.UnixMicro())).Intn(10) resultTableRow := client.NewTableRow() var exist bool newToolKit(t). autoMigrate([]client.AutoMigrateItem{ { TablePrefixWithSchema: tablePrefix, Version: "v1", TableModelDescribe: tableModelDescribe, NoEvent: noEvent, }, }). insert(&client.InsertRequest{ TablePrefixWithSchema: tablePrefix, Version: "v1", KeyColumns: []string{"id"}, TableRow: client.NewTableRow(). AddColumnValueString("id", id). AddColumnValueString("name", name). AddColumnValueTime("time", now). AddColumnValueInt("table_num", tableNum), UserID: "test", }). queryByKeys(&client.QueryByKeysRequest{ TablePrefixWithSchema: tablePrefix, Version: "v1", KeyValues: client.NewKeyValue().Add("id", id), }, resultTableRow). assertEqual(id, resultTableRow.ColumnValueString("id"), "ID不一致"). assertEqual(name, resultTableRow.ColumnValueString("name"), "名称不一致"). assertEqual(now.UnixMicro(), resultTableRow.ColumnValueTime("time").UnixMicro(), "时间不一致"). assertEqual(tableNum, resultTableRow.ColumnValueInt("table_num"), "表数量不一致"). checkExistWhere(&client.CountWhereRequest{ TablePrefixWithSchema: tablePrefix, Version: "v1", Where: client.NewClause().Equal("id", id), }, &exist). assertEqual(true, exist, "存在状态不一致"). commonCheckExist(&client.CommonCountRequest{ TablePrefixWithSchema: tablePrefix, Version: "v1", Where: client.NewClause(). Equal("id", id). Equal("name", name). Equal("table_num", tableNum), }, &exist). assertEqual(true, exist, "存在状态不一致") } func TestInsertBatch(t *testing.T) { initClient(t, "localhost:30170", "ee2d7dabe56646ce835d80873348ee0e") defer destroyClient(t, "ee2d7dabe56646ce835d80873348ee0e") tablePrefix := "test." + simpleUUID()[0:8] id1 := simpleUUID() name1 := simpleUUID() now1 := time.Now().Local() tableNum1 := rand.New(rand.NewSource(now1.UnixMicro())).Intn(10) id2 := simpleUUID() name2 := simpleUUID() now2 := time.Now().Local() tableNum2 := rand.New(rand.NewSource(now2.UnixMicro())).Intn(10) resultTableRows := make([]client.TableRow, 0) var totalCount int64 newToolKit(t). autoMigrate([]client.AutoMigrateItem{ { TablePrefixWithSchema: tablePrefix, Version: "v1", TableModelDescribe: tableModelDescribe, NoEvent: noEvent, }, }). insertBatch(&client.InsertBatchRequest{ Items: []client.InsertTableRowItem{ { TablePrefixWithSchema: tablePrefix, Version: "v1", KeyColumns: []string{"id"}, TableRows: []*client.TableRow{ client.NewTableRow(). AddColumnValueString("id", id1). AddColumnValueString("name", name1). AddColumnValueTime("time", now1). AddColumnValueInt("table_num", tableNum1), client.NewTableRow(). AddColumnValueString("id", id2). AddColumnValueString("name", name2). AddColumnValueTime("time", now2). AddColumnValueInt("table_num", tableNum2), }, }, }, }). queryByWhereAndOrderBy(&client.QueryByWhereAndOrderByRequest{ TablePrefixWithSchema: tablePrefix, Version: "v1", Where: client.NewClause(). Equal("id", id1). Equal("name", name1). Equal("table_num", tableNum1), PageNo: 1, PageSize: 1, }, &resultTableRows, &totalCount). assertEqual(1, int(totalCount), "总数不一致"). assertEqual(id1, resultTableRows[0].ColumnValueString("id"), "ID不一致"). assertEqual(name1, resultTableRows[0].ColumnValueString("name"), "名称不一致"). assertEqual(now1.UnixMicro(), resultTableRows[0].ColumnValueTime("time").UnixMicro(), "时间不一致"). assertEqual(tableNum1, resultTableRows[0].ColumnValueInt("table_num"), "表数量不一致"). commonQuery(&client.CommonQueryRequest{ TablePrefixWithSchema: tablePrefix, Version: "v1", Where: client.NewClause(). Equal("id", id2). Equal("name", name2). Equal("table_num", tableNum2), PageNo: 1, PageSize: 1, }, &resultTableRows, &totalCount). assertEqual(1, int(totalCount), "总数不一致"). assertEqual(id2, resultTableRows[0].ColumnValueString("id"), "ID不一致"). assertEqual(name2, resultTableRows[0].ColumnValueString("name"), "名称不一致"). assertEqual(now2.UnixMicro(), resultTableRows[0].ColumnValueTime("time").UnixMicro(), "时间不一致"). assertEqual(tableNum2, resultTableRows[0].ColumnValueInt("table_num"), "表数量不一致"). queryOnlyByWhereAndOrderBy(&client.QueryByWhereAndOrderByRequest{ TablePrefixWithSchema: tablePrefix, Version: "v1", Where: client.NewClause(). Equal("id", id1). Equal("name", name1). Equal("table_num", tableNum1), PageNo: 1, PageSize: 1, }, &resultTableRows). assertEqual(id1, resultTableRows[0].ColumnValueString("id"), "ID不一致"). assertEqual(name1, resultTableRows[0].ColumnValueString("name"), "名称不一致"). assertEqual(now1.UnixMicro(), resultTableRows[0].ColumnValueTime("time").UnixMicro(), "时间不一致"). assertEqual(tableNum1, resultTableRows[0].ColumnValueInt("table_num"), "表数量不一致"). commonQueryOnly(&client.CommonQueryRequest{ TablePrefixWithSchema: tablePrefix, Version: "v1", Where: client.NewClause(). Equal("id", id2). Equal("name", name2). Equal("table_num", tableNum2), PageNo: 1, PageSize: 1, }, &resultTableRows). assertEqual(id2, resultTableRows[0].ColumnValueString("id"), "ID不一致"). assertEqual(name2, resultTableRows[0].ColumnValueString("name"), "名称不一致"). assertEqual(now2.UnixMicro(), resultTableRows[0].ColumnValueTime("time").UnixMicro(), "时间不一致"). assertEqual(tableNum2, resultTableRows[0].ColumnValueInt("table_num"), "表数量不一致") } func TestUpdate(t *testing.T) { initClient(t, "localhost:30170", "ee2d7dabe56646ce835d80873348ee0e") defer destroyClient(t, "ee2d7dabe56646ce835d80873348ee0e") tablePrefix := "test." + simpleUUID()[0:8] id := simpleUUID() name := simpleUUID() now := time.Now().Local() tableNum := rand.New(rand.NewSource(now.UnixMicro())).Intn(10) newName := simpleUUID() newNow := time.Now().Local() newTableNum := rand.New(rand.NewSource(now.UnixMicro())).Intn(10) resultTableRow := client.NewTableRow() newToolKit(t). autoMigrate([]client.AutoMigrateItem{ { TablePrefixWithSchema: tablePrefix, Version: "v1", TableModelDescribe: tableModelDescribe, NoEvent: noEvent, }, }). insert(&client.InsertRequest{ TablePrefixWithSchema: tablePrefix, Version: "v1", KeyColumns: []string{"id"}, TableRow: client.NewTableRow(). AddColumnValueString("id", id). AddColumnValueString("name", name). AddColumnValueTime("time", now). AddColumnValueInt("table_num", tableNum), UserID: "test", }). update(&client.UpdateRequest{ TablePrefixWithSchema: tablePrefix, Version: "v1", KeyValues: client.NewKeyValue().Add("id", id), NewTableRow: client.NewTableRow(). AddColumnValueString("id", id). AddColumnValueString("name", newName). AddColumnValueTime("time", newNow). AddColumnValueInt("table_num", newTableNum), UserID: "test", }). queryByKeys(&client.QueryByKeysRequest{ TablePrefixWithSchema: tablePrefix, Version: "v1", KeyValues: client.NewKeyValue().Add("id", id), }, resultTableRow). assertEqual(id, resultTableRow.ColumnValueString("id"), "ID不一致"). assertEqual(newName, resultTableRow.ColumnValueString("name"), "名称不一致"). assertEqual(newNow.UnixMicro(), resultTableRow.ColumnValueTime("time").UnixMicro(), "时间不一致"). assertEqual(newTableNum, resultTableRow.ColumnValueInt("table_num"), "表数量不一致") } func TestUpdateWhere(t *testing.T) { initClient(t, "localhost:30170", "ee2d7dabe56646ce835d80873348ee0e") defer destroyClient(t, "ee2d7dabe56646ce835d80873348ee0e") tablePrefix := "test." + simpleUUID()[0:8] id := simpleUUID() name := simpleUUID() now := time.Now().Local() tableNum := rand.New(rand.NewSource(now.UnixMicro())).Intn(10) newName := simpleUUID() newNow := time.Now().Local() newTableNum := rand.New(rand.NewSource(now.UnixMicro())).Intn(10) resultTableRow := client.NewTableRow() newToolKit(t). autoMigrate([]client.AutoMigrateItem{ { TablePrefixWithSchema: tablePrefix, Version: "v1", TableModelDescribe: tableModelDescribe, NoEvent: noEvent, }, }). insert(&client.InsertRequest{ TablePrefixWithSchema: tablePrefix, Version: "v1", KeyColumns: []string{"id"}, TableRow: client.NewTableRow(). AddColumnValueString("id", id). AddColumnValueString("name", name). AddColumnValueTime("time", now). AddColumnValueInt("table_num", tableNum), UserID: "test", }). updateWhere(&client.UpdateWhereRequest{ TablePrefixWithSchema: tablePrefix, Version: "v1", KeyColumns: []string{"id"}, Where: client.NewClause().Equal("name", name), NewTableRow: client.NewTableRow(). AddColumnValueString("id", id). AddColumnValueString("name", newName). AddColumnValueTime("time", newNow). AddColumnValueInt("table_num", newTableNum), UserID: "test", }). queryByKeys(&client.QueryByKeysRequest{ TablePrefixWithSchema: tablePrefix, Version: "v1", KeyValues: client.NewKeyValue().Add("id", id), }, resultTableRow). assertEqual(id, resultTableRow.ColumnValueString("id"), "ID不一致"). assertEqual(newName, resultTableRow.ColumnValueString("name"), "名称不一致"). assertEqual(newNow.UnixMicro(), resultTableRow.ColumnValueTime("time").UnixMicro(), "时间不一致"). assertEqual(newTableNum, resultTableRow.ColumnValueInt("table_num"), "表数量不一致") } func TestDelete(t *testing.T) { initClient(t, "localhost:30170", "ee2d7dabe56646ce835d80873348ee0e") defer destroyClient(t, "ee2d7dabe56646ce835d80873348ee0e") tablePrefix := "test." + simpleUUID()[0:8] id := simpleUUID() name := simpleUUID() now := time.Now().Local() tableNum := rand.New(rand.NewSource(now.UnixMicro())).Intn(10) var count int64 newToolKit(t). autoMigrate([]client.AutoMigrateItem{ { TablePrefixWithSchema: tablePrefix, Version: "v1", TableModelDescribe: tableModelDescribe, NoEvent: noEvent, }, }). insert(&client.InsertRequest{ TablePrefixWithSchema: tablePrefix, Version: "v1", KeyColumns: []string{"id"}, TableRow: client.NewTableRow(). AddColumnValueString("id", id). AddColumnValueString("name", name). AddColumnValueTime("time", now). AddColumnValueInt("table_num", tableNum), UserID: "test", }). delete(&client.DeleteRequest{ TablePrefixWithSchema: tablePrefix, Version: "v1", KeyValues: client.NewKeyValue().Add("id", id), UserID: "test", }). countWhere(&client.CountWhereRequest{ TablePrefixWithSchema: tablePrefix, Version: "v1", Where: client.NewClause().Equal("id", id), }, &count). assertEqual(int64(0), count, "数量不一致") } func TestDeleteWhere(t *testing.T) { initClient(t, "localhost:30170", "ee2d7dabe56646ce835d80873348ee0e") defer destroyClient(t, "ee2d7dabe56646ce835d80873348ee0e") tablePrefix := "test." + simpleUUID()[0:8] id := simpleUUID() name := simpleUUID() now := time.Now().Local() tableNum := rand.New(rand.NewSource(now.UnixMicro())).Intn(10) var count int64 newToolKit(t). autoMigrate([]client.AutoMigrateItem{ { TablePrefixWithSchema: tablePrefix, Version: "v1", TableModelDescribe: tableModelDescribe, NoEvent: noEvent, }, }). insert(&client.InsertRequest{ TablePrefixWithSchema: tablePrefix, Version: "v1", KeyColumns: []string{"id"}, TableRow: client.NewTableRow(). AddColumnValueString("id", id). AddColumnValueString("name", name). AddColumnValueTime("time", now). AddColumnValueInt("table_num", tableNum), UserID: "test", }). deleteWhere(&client.DeleteWhereRequest{ TablePrefixWithSchema: tablePrefix, Version: "v1", KeyColumns: []string{"id"}, Where: client.NewClause().Equal("name", name), UserID: "test", }). countWhere(&client.CountWhereRequest{ TablePrefixWithSchema: tablePrefix, Version: "v1", Where: client.NewClause().Equal("id", id), }, &count). assertEqual(int64(0), count, "数量不一致") } func TestReply(t *testing.T) { initClient(t, "localhost:30170", "ee2d7dabe56646ce835d80873348ee0e") defer destroyClient(t, "ee2d7dabe56646ce835d80873348ee0e") tablePrefix := "test." + simpleUUID()[0:8] id := simpleUUID() name := simpleUUID() now := time.Now().Local() tableNum := rand.New(rand.NewSource(now.UnixMicro())).Intn(10) resultTableRow := client.NewTableRow() newToolKit(t). autoMigrate([]client.AutoMigrateItem{ { TablePrefixWithSchema: tablePrefix, Version: "v1", TableModelDescribe: tableModelDescribe, NoEvent: noEvent, }, }). insert(&client.InsertRequest{ TablePrefixWithSchema: tablePrefix, Version: "v1", KeyColumns: []string{"id"}, TableRow: client.NewTableRow(). AddColumnValueString("id", id). AddColumnValueString("name", name). AddColumnValueTime("time", now). AddColumnValueInt("table_num", tableNum), UserID: "test", }). reply(&client.ReplayRequest{ TablePrefixWithSchema: tablePrefix, Version: "v1", KeyValues: client.NewKeyValue().Add("id", id), UserID: "test", }). queryByKeys(&client.QueryByKeysRequest{ TablePrefixWithSchema: tablePrefix, Version: "v1", KeyValues: client.NewKeyValue().Add("id", id), }, resultTableRow). assertEqual(id, resultTableRow.ColumnValueString("id"), "ID不一致"). assertEqual(name, resultTableRow.ColumnValueString("name"), "名称不一致"). assertEqual(now.UnixMicro(), resultTableRow.ColumnValueTime("time").UnixMicro(), "时间不一致"). assertEqual(tableNum, resultTableRow.ColumnValueInt("table_num"), "表数量不一致") } func TestEventQuery(t *testing.T) { if noEvent { return } initClient(t, "localhost:30170", "ee2d7dabe56646ce835d80873348ee0e") defer destroyClient(t, "ee2d7dabe56646ce835d80873348ee0e") tablePrefix := "test." + simpleUUID()[0:8] id := simpleUUID() name := simpleUUID() now := time.Now().Local() tableNum := rand.New(rand.NewSource(now.UnixMicro())).Intn(10) newName := simpleUUID() newNow := time.Now().Local() newTableNum := rand.New(rand.NewSource(now.UnixMicro())).Intn(10) var exist bool var totalCount int64 eventInfos := make([]client.EventInfo, 0) newToolKit(t). autoMigrate([]client.AutoMigrateItem{ { TablePrefixWithSchema: tablePrefix, Version: "v1", TableModelDescribe: tableModelDescribe, NoEvent: noEvent, }, }). insert(&client.InsertRequest{ TablePrefixWithSchema: tablePrefix, Version: "v1", KeyColumns: []string{"id"}, TableRow: client.NewTableRow(). AddColumnValueString("id", id). AddColumnValueString("name", name). AddColumnValueTime("time", now). AddColumnValueInt("table_num", tableNum), 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{ TablePrefixWithSchema: tablePrefix, Version: "v1", KeyValues: client.NewKeyValue().Add("id", id), NewTableRow: client.NewTableRow(). AddColumnValueString("id", id). AddColumnValueString("name", newName). AddColumnValueTime("time", newNow). AddColumnValueInt("table_num", newTableNum), UserID: "test", }). countEventByKeys(&client.CountEventByKeysRequest{ TablePrefixWithSchema: tablePrefix, KeyValues: []string{id}, }, &totalCount). assertEqual(2, int(totalCount), "总数不一致"). commonCountEvent(&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), }, &totalCount). assertEqual(1, int(totalCount), "总数不一致"). commonCountEvent(&client.CommonCountEventRequest{ TablePrefixWithSchema: tablePrefix, KeyValues: []string{id}, Version: "v1", Operation: "update", CreatorID: "test", StartCreatedTime: now.Format(time.DateTime), EndCreatedTime: now.Add(time.Second).Format(time.DateTime), }, &totalCount). assertEqual(1, int(totalCount), "总数不一致"). eventQueryByKeys(&client.EventQueryByKeysRequest{ TablePrefixWithSchema: tablePrefix, KeyValues: []string{id}, PageNo: 0, PageSize: 0, }, &eventInfos, &totalCount). assertEqual(2, int(totalCount), "总数不一致"). assertEqual(2, len(eventInfos), "事件数量不一致"). assertEqual(id, eventInfos[0].Key, "关键字段不一致"). assertEqual("v1", eventInfos[0].Version, "版本不一致"). assertEqual("create", eventInfos[0].Operation, "操作不一致"). assertEqual("test", eventInfos[0].CreatorID, "创建者ID不一致"). assertNotEmpty(eventInfos[0].CreateTime, "创建事件为空"). assertNotEmpty(eventInfos[0].Value, "值为空不一致"). assertEqual(id, eventInfos[1].Key, "关键字段不一致"). assertEqual("v1", eventInfos[1].Version, "版本不一致"). assertEqual("update", eventInfos[1].Operation, "操作不一致"). assertEqual("test", eventInfos[1].CreatorID, "创建者ID不一致"). assertNotEmpty(eventInfos[1].CreateTime, "创建事件为空"). assertNotEmpty(eventInfos[1].Value, "值为空不一致"). eventQueryByKeys(&client.EventQueryByKeysRequest{ TablePrefixWithSchema: tablePrefix, KeyValues: []string{id}, PageNo: 1, PageSize: 1, }, &eventInfos, &totalCount). assertEqual(2, int(totalCount), "总数不一致"). assertEqual(1, len(eventInfos), "事件数量不一致"). assertEqual(id, eventInfos[0].Key, "关键字段不一致"). assertEqual("v1", eventInfos[0].Version, "版本不一致"). assertEqual("create", eventInfos[0].Operation, "操作不一致"). assertEqual("test", eventInfos[0].CreatorID, "创建者ID不一致"). assertNotEmpty(eventInfos[0].CreateTime, "创建事件为空"). assertNotEmpty(eventInfos[0].Value, "值为空不一致"). commonEventQuery(&client.CommonEventQueryRequest{ TablePrefixWithSchema: tablePrefix, KeyValues: []string{id}, Version: "v1", Operation: "create", CreatorID: "test", StartCreatedTime: now.Format(time.DateTime), EndCreatedTime: now.Add(time.Second).Format(time.DateTime), PageNo: 0, PageSize: 0, }, &eventInfos, &totalCount). assertEqual(1, int(totalCount), "总数不一致"). assertEqual(1, len(eventInfos), "事件数量不一致"). assertEqual(id, eventInfos[0].Key, "关键字段不一致"). assertEqual("v1", eventInfos[0].Version, "版本不一致"). assertEqual("create", eventInfos[0].Operation, "操作不一致"). assertEqual("test", eventInfos[0].CreatorID, "创建者ID不一致"). assertNotEmpty(eventInfos[0].CreateTime, "创建事件为空"). assertNotEmpty(eventInfos[0].Value, "值为空不一致"). commonEventQuery(&client.CommonEventQueryRequest{ TablePrefixWithSchema: tablePrefix, KeyValues: []string{id}, Version: "v1", Operation: "update", CreatorID: "test", StartCreatedTime: now.Format(time.DateTime), EndCreatedTime: now.Add(time.Second).Format(time.DateTime), PageNo: 0, PageSize: 0, }, &eventInfos, &totalCount). assertEqual(1, int(totalCount), "总数不一致"). assertEqual(1, len(eventInfos), "事件数量不一致"). assertEqual(id, eventInfos[0].Key, "关键字段不一致"). assertEqual("v1", eventInfos[0].Version, "版本不一致"). assertEqual("update", eventInfos[0].Operation, "操作不一致"). assertEqual("test", eventInfos[0].CreatorID, "创建者ID不一致"). assertNotEmpty(eventInfos[0].CreateTime, "创建事件为空"). assertNotEmpty(eventInfos[0].Value, "值为空不一致"). eventQueryOnlyByKeys(&client.EventQueryByKeysRequest{ TablePrefixWithSchema: tablePrefix, KeyValues: []string{id}, PageNo: 0, PageSize: 0, }, &eventInfos). assertEqual(2, len(eventInfos), "事件数量不一致"). assertEqual(id, eventInfos[0].Key, "关键字段不一致"). assertEqual("v1", eventInfos[0].Version, "版本不一致"). assertEqual("create", eventInfos[0].Operation, "操作不一致"). assertEqual("test", eventInfos[0].CreatorID, "创建者ID不一致"). assertNotEmpty(eventInfos[0].CreateTime, "创建事件为空"). assertNotEmpty(eventInfos[0].Value, "值为空不一致"). assertEqual(id, eventInfos[1].Key, "关键字段不一致"). assertEqual("v1", eventInfos[1].Version, "版本不一致"). assertEqual("update", eventInfos[1].Operation, "操作不一致"). assertEqual("test", eventInfos[1].CreatorID, "创建者ID不一致"). assertNotEmpty(eventInfos[1].CreateTime, "创建事件为空"). assertNotEmpty(eventInfos[1].Value, "值为空不一致"). eventQueryOnlyByKeys(&client.EventQueryByKeysRequest{ TablePrefixWithSchema: tablePrefix, KeyValues: []string{id}, PageNo: 1, PageSize: 1, }, &eventInfos). assertEqual(1, len(eventInfos), "事件数量不一致"). assertEqual(id, eventInfos[0].Key, "关键字段不一致"). assertEqual("v1", eventInfos[0].Version, "版本不一致"). assertEqual("create", eventInfos[0].Operation, "操作不一致"). assertEqual("test", eventInfos[0].CreatorID, "创建者ID不一致"). assertNotEmpty(eventInfos[0].CreateTime, "创建事件为空"). assertNotEmpty(eventInfos[0].Value, "值为空不一致"). commonEventQueryOnly(&client.CommonEventQueryRequest{ TablePrefixWithSchema: tablePrefix, KeyValues: []string{id}, Version: "v1", Operation: "create", CreatorID: "test", StartCreatedTime: now.Format(time.DateTime), EndCreatedTime: now.Add(time.Second).Format(time.DateTime), PageNo: 0, PageSize: 0, }, &eventInfos). assertEqual(1, len(eventInfos), "事件数量不一致"). assertEqual(id, eventInfos[0].Key, "关键字段不一致"). assertEqual("v1", eventInfos[0].Version, "版本不一致"). assertEqual("create", eventInfos[0].Operation, "操作不一致"). assertEqual("test", eventInfos[0].CreatorID, "创建者ID不一致"). assertNotEmpty(eventInfos[0].CreateTime, "创建事件为空"). assertNotEmpty(eventInfos[0].Value, "值为空不一致"). commonEventQueryOnly(&client.CommonEventQueryRequest{ TablePrefixWithSchema: tablePrefix, KeyValues: []string{id}, Version: "v1", Operation: "update", CreatorID: "test", StartCreatedTime: now.Format(time.DateTime), EndCreatedTime: now.Add(time.Second).Format(time.DateTime), PageNo: 0, PageSize: 0, }, &eventInfos). assertEqual(1, len(eventInfos), "事件数量不一致"). assertEqual(id, eventInfos[0].Key, "关键字段不一致"). assertEqual("v1", eventInfos[0].Version, "版本不一致"). assertEqual("update", eventInfos[0].Operation, "操作不一致"). assertEqual("test", eventInfos[0].CreatorID, "创建者ID不一致"). assertNotEmpty(eventInfos[0].CreateTime, "创建事件为空"). assertNotEmpty(eventInfos[0].Value, "值为空不一致"). delete(&client.DeleteRequest{ TablePrefixWithSchema: tablePrefix, Version: "v1", KeyValues: client.NewKeyValue().Add("id", id), 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{ TablePrefixWithSchema: tablePrefix, KeyValues: []string{id}, }, &totalCount). assertEqual(3, int(totalCount), "总数不一致"). commonCountEventHistory(&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), }, &totalCount). assertEqual(1, int(totalCount), "总数不一致"). commonCountEventHistory(&client.CommonCountEventRequest{ TablePrefixWithSchema: tablePrefix, KeyValues: []string{id}, Version: "v1", Operation: "update", CreatorID: "test", StartCreatedTime: now.Format(time.DateTime), EndCreatedTime: now.Add(time.Second).Format(time.DateTime), }, &totalCount). assertEqual(1, int(totalCount), "总数不一致"). commonCountEventHistory(&client.CommonCountEventRequest{ TablePrefixWithSchema: tablePrefix, KeyValues: []string{id}, Version: "v1", Operation: "delete", CreatorID: "test", StartCreatedTime: now.Format(time.DateTime), EndCreatedTime: now.Add(time.Second).Format(time.DateTime), }, &totalCount). assertEqual(1, int(totalCount), "总数不一致"). eventHistoryQueryByKeys(&client.EventQueryByKeysRequest{ TablePrefixWithSchema: tablePrefix, KeyValues: []string{id}, PageNo: 0, PageSize: 0, }, &eventInfos, &totalCount). assertEqual(3, int(totalCount), "总数不一致"). assertEqual(3, len(eventInfos), "事件数量不一致"). assertEqual(id, eventInfos[0].Key, "关键字段不一致"). assertEqual("v1", eventInfos[0].Version, "版本不一致"). assertEqual("create", eventInfos[0].Operation, "操作不一致"). assertEqual("test", eventInfos[0].CreatorID, "创建者ID不一致"). assertNotEmpty(eventInfos[0].CreateTime, "创建事件为空"). assertNotEmpty(eventInfos[0].Value, "值为空不一致"). assertEqual(id, eventInfos[1].Key, "关键字段不一致"). assertEqual("v1", eventInfos[1].Version, "版本不一致"). assertEqual("update", eventInfos[1].Operation, "操作不一致"). assertEqual("test", eventInfos[1].CreatorID, "创建者ID不一致"). assertNotEmpty(eventInfos[1].CreateTime, "创建事件为空"). assertNotEmpty(eventInfos[1].Value, "值为空不一致"). assertEqual(id, eventInfos[2].Key, "关键字段不一致"). assertEqual("v1", eventInfos[2].Version, "版本不一致"). assertEqual("delete", eventInfos[2].Operation, "操作不一致"). assertEqual("test", eventInfos[2].CreatorID, "创建者ID不一致"). assertNotEmpty(eventInfos[2].CreateTime, "创建事件为空"). assertEqual("", eventInfos[2].Value, "值为空不一致"). eventHistoryQueryByKeys(&client.EventQueryByKeysRequest{ TablePrefixWithSchema: tablePrefix, KeyValues: []string{id}, PageNo: 1, PageSize: 1, }, &eventInfos, &totalCount). assertEqual(3, int(totalCount), "总数不一致"). assertEqual(1, len(eventInfos), "事件数量不一致"). assertEqual(id, eventInfos[0].Key, "关键字段不一致"). assertEqual("v1", eventInfos[0].Version, "版本不一致"). assertEqual("create", eventInfos[0].Operation, "操作不一致"). assertEqual("test", eventInfos[0].CreatorID, "创建者ID不一致"). assertNotEmpty(eventInfos[0].CreateTime, "创建事件为空"). assertNotEmpty(eventInfos[0].Value, "值为空不一致"). commonEventHistoryQuery(&client.CommonEventQueryRequest{ TablePrefixWithSchema: tablePrefix, KeyValues: []string{id}, Version: "v1", Operation: "create", CreatorID: "test", StartCreatedTime: now.Format(time.DateTime), EndCreatedTime: now.Add(time.Second).Format(time.DateTime), PageNo: 0, PageSize: 0, }, &eventInfos, &totalCount). assertEqual(1, int(totalCount), "总数不一致"). assertEqual(1, len(eventInfos), "事件数量不一致"). assertEqual(id, eventInfos[0].Key, "关键字段不一致"). assertEqual("v1", eventInfos[0].Version, "版本不一致"). assertEqual("create", eventInfos[0].Operation, "操作不一致"). assertEqual("test", eventInfos[0].CreatorID, "创建者ID不一致"). assertNotEmpty(eventInfos[0].CreateTime, "创建事件为空"). assertNotEmpty(eventInfos[0].Value, "值为空不一致"). commonEventHistoryQuery(&client.CommonEventQueryRequest{ TablePrefixWithSchema: tablePrefix, KeyValues: []string{id}, Version: "v1", Operation: "update", CreatorID: "test", StartCreatedTime: now.Format(time.DateTime), EndCreatedTime: now.Add(time.Second).Format(time.DateTime), PageNo: 0, PageSize: 0, }, &eventInfos, &totalCount). assertEqual(1, int(totalCount), "总数不一致"). assertEqual(1, len(eventInfos), "事件数量不一致"). assertEqual(id, eventInfos[0].Key, "关键字段不一致"). assertEqual("v1", eventInfos[0].Version, "版本不一致"). assertEqual("update", eventInfos[0].Operation, "操作不一致"). assertEqual("test", eventInfos[0].CreatorID, "创建者ID不一致"). assertNotEmpty(eventInfos[0].CreateTime, "创建事件为空"). assertNotEmpty(eventInfos[0].Value, "值为空不一致"). commonEventHistoryQuery(&client.CommonEventQueryRequest{ TablePrefixWithSchema: tablePrefix, KeyValues: []string{id}, Version: "v1", Operation: "delete", CreatorID: "test", StartCreatedTime: now.Format(time.DateTime), EndCreatedTime: now.Add(time.Second).Format(time.DateTime), PageNo: 0, PageSize: 0, }, &eventInfos, &totalCount). assertEqual(1, int(totalCount), "总数不一致"). assertEqual(1, len(eventInfos), "事件数量不一致"). assertEqual(id, eventInfos[0].Key, "关键字段不一致"). assertEqual("v1", eventInfos[0].Version, "版本不一致"). assertEqual("delete", eventInfos[0].Operation, "操作不一致"). assertEqual("test", eventInfos[0].CreatorID, "创建者ID不一致"). assertNotEmpty(eventInfos[0].CreateTime, "创建事件为空"). assertEqual("", eventInfos[0].Value, "值为空不一致"). eventHistoryQueryOnlyByKeys(&client.EventQueryByKeysRequest{ TablePrefixWithSchema: tablePrefix, KeyValues: []string{id}, PageNo: 0, PageSize: 0, }, &eventInfos). assertEqual(3, len(eventInfos), "事件数量不一致"). assertEqual(id, eventInfos[0].Key, "关键字段不一致"). assertEqual("v1", eventInfos[0].Version, "版本不一致"). assertEqual("create", eventInfos[0].Operation, "操作不一致"). assertEqual("test", eventInfos[0].CreatorID, "创建者ID不一致"). assertNotEmpty(eventInfos[0].CreateTime, "创建事件为空"). assertNotEmpty(eventInfos[0].Value, "值为空不一致"). assertEqual(id, eventInfos[1].Key, "关键字段不一致"). assertEqual("v1", eventInfos[1].Version, "版本不一致"). assertEqual("update", eventInfos[1].Operation, "操作不一致"). assertEqual("test", eventInfos[1].CreatorID, "创建者ID不一致"). assertNotEmpty(eventInfos[1].CreateTime, "创建事件为空"). assertNotEmpty(eventInfos[1].Value, "值为空不一致"). assertEqual(id, eventInfos[2].Key, "关键字段不一致"). assertEqual("v1", eventInfos[2].Version, "版本不一致"). assertEqual("delete", eventInfos[2].Operation, "操作不一致"). assertEqual("test", eventInfos[2].CreatorID, "创建者ID不一致"). assertNotEmpty(eventInfos[2].CreateTime, "创建事件为空"). assertEqual("", eventInfos[2].Value, "值为空不一致"). eventHistoryQueryOnlyByKeys(&client.EventQueryByKeysRequest{ TablePrefixWithSchema: tablePrefix, KeyValues: []string{id}, PageNo: 1, PageSize: 1, }, &eventInfos). assertEqual(1, len(eventInfos), "事件数量不一致"). assertEqual(id, eventInfos[0].Key, "关键字段不一致"). assertEqual("v1", eventInfos[0].Version, "版本不一致"). assertEqual("create", eventInfos[0].Operation, "操作不一致"). assertEqual("test", eventInfos[0].CreatorID, "创建者ID不一致"). assertNotEmpty(eventInfos[0].CreateTime, "创建事件为空"). assertNotEmpty(eventInfos[0].Value, "值为空不一致"). commonEventHistoryQueryOnly(&client.CommonEventQueryRequest{ TablePrefixWithSchema: tablePrefix, KeyValues: []string{id}, Version: "v1", Operation: "create", CreatorID: "test", StartCreatedTime: now.Format(time.DateTime), EndCreatedTime: now.Add(time.Second).Format(time.DateTime), PageNo: 0, PageSize: 0, }, &eventInfos). assertEqual(1, len(eventInfos), "事件数量不一致"). assertEqual(id, eventInfos[0].Key, "关键字段不一致"). assertEqual("v1", eventInfos[0].Version, "版本不一致"). assertEqual("create", eventInfos[0].Operation, "操作不一致"). assertEqual("test", eventInfos[0].CreatorID, "创建者ID不一致"). assertNotEmpty(eventInfos[0].CreateTime, "创建事件为空"). assertNotEmpty(eventInfos[0].Value, "值为空不一致"). commonEventHistoryQueryOnly(&client.CommonEventQueryRequest{ TablePrefixWithSchema: tablePrefix, KeyValues: []string{id}, Version: "v1", Operation: "update", CreatorID: "test", StartCreatedTime: now.Format(time.DateTime), EndCreatedTime: now.Add(time.Second).Format(time.DateTime), PageNo: 0, PageSize: 0, }, &eventInfos). assertEqual(1, len(eventInfos), "事件数量不一致"). assertEqual(id, eventInfos[0].Key, "关键字段不一致"). assertEqual("v1", eventInfos[0].Version, "版本不一致"). assertEqual("update", eventInfos[0].Operation, "操作不一致"). assertEqual("test", eventInfos[0].CreatorID, "创建者ID不一致"). assertNotEmpty(eventInfos[0].CreateTime, "创建事件为空"). assertNotEmpty(eventInfos[0].Value, "值为空不一致"). commonEventHistoryQueryOnly(&client.CommonEventQueryRequest{ TablePrefixWithSchema: tablePrefix, KeyValues: []string{id}, Version: "v1", Operation: "delete", CreatorID: "test", StartCreatedTime: now.Format(time.DateTime), EndCreatedTime: now.Add(time.Second).Format(time.DateTime), PageNo: 0, PageSize: 0, }, &eventInfos). assertEqual(1, len(eventInfos), "事件数量不一致"). assertEqual(id, eventInfos[0].Key, "关键字段不一致"). assertEqual("v1", eventInfos[0].Version, "版本不一致"). assertEqual("delete", eventInfos[0].Operation, "操作不一致"). assertEqual("test", eventInfos[0].CreatorID, "创建者ID不一致"). assertNotEmpty(eventInfos[0].CreateTime, "创建事件为空"). assertEqual("", eventInfos[0].Value, "值为空不一致") }