|
@@ -218,8 +218,64 @@ func TestApiV1Operate(t *testing.T) {
|
|
|
})
|
|
|
|
|
|
operate(t, fmt.Sprintf(sqlInsertFormat, tablePrefix, id, name, now.Format(time.DateTime), tableNum), keyColumns)
|
|
|
+
|
|
|
+ tableRows := operate(t, fmt.Sprintf(sqlSelectFormat, tablePrefix, id), nil)
|
|
|
+
|
|
|
+ if tableRows[0]["id"] != id {
|
|
|
+ t.Fatal("id不正确")
|
|
|
+ }
|
|
|
+
|
|
|
+ if tableRows[0]["name"] != name {
|
|
|
+ t.Fatal("name不正确")
|
|
|
+ }
|
|
|
+
|
|
|
+ if tableRows[0]["time"] != now.Format("2006-01-02T15:04:05+08:00") {
|
|
|
+ t.Fatal("time不正确")
|
|
|
+ }
|
|
|
+
|
|
|
+ if tableRows[0]["table_num"] != float64(tableNum) {
|
|
|
+ t.Fatal("tableNum不正确")
|
|
|
+ }
|
|
|
+
|
|
|
+ tableRows = operate(t, fmt.Sprintf(sqlCountFormat, tablePrefix, id), nil)
|
|
|
+
|
|
|
+ if tableRows[0]["count"] != float64(1) {
|
|
|
+ t.Fatal("数量不正确")
|
|
|
+ }
|
|
|
+
|
|
|
operate(t, fmt.Sprintf(sqlUpdateFormat, tablePrefix, newName, newNow.Format(time.DateTime), newTableNum, id), keyColumns)
|
|
|
+
|
|
|
+ tableRows = operate(t, fmt.Sprintf(sqlSelectFormat, tablePrefix, id), nil)
|
|
|
+
|
|
|
+ if tableRows[0]["id"] != id {
|
|
|
+ t.Fatal("id不正确")
|
|
|
+ }
|
|
|
+
|
|
|
+ if tableRows[0]["name"] != newName {
|
|
|
+ t.Fatal("name不正确")
|
|
|
+ }
|
|
|
+
|
|
|
+ if tableRows[0]["time"] != newNow.Format("2006-01-02T15:04:05+08:00") {
|
|
|
+ t.Fatal("time不正确")
|
|
|
+ }
|
|
|
+
|
|
|
+ if tableRows[0]["table_num"] != float64(newTableNum) {
|
|
|
+ t.Fatal("tableNum不正确")
|
|
|
+ }
|
|
|
+
|
|
|
+ tableRows = operate(t, fmt.Sprintf(sqlCountFormat, tablePrefix, id), nil)
|
|
|
+
|
|
|
+ if tableRows[0]["count"] != float64(1) {
|
|
|
+ t.Fatal("数量不正确")
|
|
|
+ }
|
|
|
+
|
|
|
operate(t, fmt.Sprintf(sqlDeleteFormat, tablePrefix, id), keyColumns)
|
|
|
+
|
|
|
+ tableRows = operate(t, fmt.Sprintf(sqlCountFormat, tablePrefix, id), nil)
|
|
|
+
|
|
|
+ if tableRows[0]["count"] != float64(0) {
|
|
|
+ t.Fatal("数量不正确")
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
func autoMigrate(t *testing.T, items []client.AutoMigrateItem) {
|
|
@@ -264,7 +320,7 @@ func operateParse(t *testing.T, sql string) map[string]any {
|
|
|
func operate(t *testing.T, sql string, keyColumns []string) []map[string]any {
|
|
|
result := new(struct {
|
|
|
response.MsgResponse
|
|
|
- TableRows []map[string]any `json:"table_rows"`
|
|
|
+ TableRows []map[string]any `json:"tableRows"`
|
|
|
})
|
|
|
|
|
|
resp, err := resty.New().R().
|