(t *testing.T)
| 115 | } |
| 116 | |
| 117 | func TestDoInsert(t *testing.T) { |
| 118 | gtest.C(t, func(t *gtest.T) { |
| 119 | createTable("t_user") |
| 120 | defer dropTable("t_user") |
| 121 | |
| 122 | i := 10 |
| 123 | data := g.Map{ |
| 124 | "id": i, |
| 125 | "passport": fmt.Sprintf(`t%d`, i), |
| 126 | "password": fmt.Sprintf(`p%d`, i), |
| 127 | "nickname": fmt.Sprintf(`T%d`, i), |
| 128 | "create_time": gtime.Now(), |
| 129 | } |
| 130 | _, err := db.Insert(context.Background(), "t_user", data) |
| 131 | gtest.AssertNil(err) |
| 132 | |
| 133 | }) |
| 134 | |
| 135 | gtest.C(t, func(t *gtest.T) { |
| 136 | createTable("t_user") |
| 137 | defer dropTable("t_user") |
| 138 | |
| 139 | i := 10 |
| 140 | data := g.Map{ |
| 141 | // "id": i, |
| 142 | "passport": fmt.Sprintf(`t%d`, i), |
| 143 | "password": fmt.Sprintf(`p%d`, i), |
| 144 | "nickname": fmt.Sprintf(`T%d`, i), |
| 145 | "create_time": gtime.Now(), |
| 146 | } |
| 147 | // Save without OnConflict should fail (missing conflict columns) |
| 148 | _, err := db.Save(context.Background(), "t_user", data, 10) |
| 149 | gtest.AssertNE(err, nil) |
| 150 | |
| 151 | // Replace should fail because primary key 'id' is not in the data |
| 152 | _, err = db.Replace(context.Background(), "t_user", data, 10) |
| 153 | gtest.AssertNE(err, nil) |
| 154 | }) |
| 155 | } |
| 156 | |
| 157 | func TestDoInsertGetId(t *testing.T) { |
| 158 | // create test table |
nothing calls this directly
no test coverage detected
searching dependent graphs…