(t *testing.T)
| 249 | } |
| 250 | |
| 251 | func TestReadWriteTransaction(t *testing.T) { |
| 252 | if skipIntegrateTest { |
| 253 | t.Skip("Integration tests skipped") |
| 254 | } |
| 255 | |
| 256 | t.Run("begin, insert, and commit", func(t *testing.T) { |
| 257 | ctx, cancel := context.WithTimeout(context.Background(), 180*time.Second) |
| 258 | defer cancel() |
| 259 | |
| 260 | session, tableId, tearDown := setup(t, ctx, []string{}) |
| 261 | defer tearDown() |
| 262 | |
| 263 | // begin |
| 264 | stmt, err := BuildStatement("BEGIN") |
| 265 | if err != nil { |
| 266 | t.Fatalf("invalid statement: error=%s", err) |
| 267 | } |
| 268 | |
| 269 | result, err := stmt.Execute(ctx, session) |
| 270 | if err != nil { |
| 271 | t.Fatalf("unexpected error happened: %s", err) |
| 272 | } |
| 273 | |
| 274 | compareResult(t, result, &Result{ |
| 275 | AffectedRows: 0, |
| 276 | IsMutation: true, |
| 277 | }) |
| 278 | |
| 279 | // insert |
| 280 | stmt, err = BuildStatement(fmt.Sprintf("INSERT INTO %s (id, active) VALUES (1, true), (2, false)", tableId)) |
| 281 | if err != nil { |
| 282 | t.Fatalf("invalid statement: error=%s", err) |
| 283 | } |
| 284 | |
| 285 | result, err = stmt.Execute(ctx, session) |
| 286 | if err != nil { |
| 287 | t.Fatalf("unexpected error happened: %s", err) |
| 288 | } |
| 289 | |
| 290 | compareResult(t, result, &Result{ |
| 291 | AffectedRows: 2, |
| 292 | IsMutation: true, |
| 293 | }) |
| 294 | |
| 295 | // commit |
| 296 | stmt, err = BuildStatement("COMMIT") |
| 297 | if err != nil { |
| 298 | t.Fatalf("invalid statement: error=%s", err) |
| 299 | } |
| 300 | |
| 301 | result, err = stmt.Execute(ctx, session) |
| 302 | if err != nil { |
| 303 | t.Fatalf("unexpected error happened: %s", err) |
| 304 | } |
| 305 | |
| 306 | compareResult(t, result, &Result{ |
| 307 | AffectedRows: 0, |
| 308 | IsMutation: true, |
nothing calls this directly
no test coverage detected