(t *testing.T)
| 449 | } |
| 450 | |
| 451 | func TestMultiQuery(t *testing.T) { |
| 452 | runTestsWithMultiStatement(t, dsn, func(dbt *DBTest) { |
| 453 | // Create Table |
| 454 | dbt.mustExec("CREATE TABLE `test` (`id` int(11) NOT NULL, `value` int(11) NOT NULL) ") |
| 455 | |
| 456 | // Create Data |
| 457 | res := dbt.mustExec("INSERT INTO test VALUES (1, 1)") |
| 458 | count, err := res.RowsAffected() |
| 459 | if err != nil { |
| 460 | dbt.Fatalf("res.RowsAffected() returned error: %s", err.Error()) |
| 461 | } |
| 462 | if count != 1 { |
| 463 | dbt.Fatalf("expected 1 affected row, got %d", count) |
| 464 | } |
| 465 | |
| 466 | // Update |
| 467 | res = dbt.mustExec("UPDATE test SET value = 3 WHERE id = 1; UPDATE test SET value = 4 WHERE id = 1; UPDATE test SET value = 5 WHERE id = 1;") |
| 468 | count, err = res.RowsAffected() |
| 469 | if err != nil { |
| 470 | dbt.Fatalf("res.RowsAffected() returned error: %s", err.Error()) |
| 471 | } |
| 472 | if count != 1 { |
| 473 | dbt.Fatalf("expected 1 affected row, got %d", count) |
| 474 | } |
| 475 | |
| 476 | // Read |
| 477 | var out int |
| 478 | rows := dbt.mustQuery("SELECT value FROM test WHERE id=1;") |
| 479 | if rows.Next() { |
| 480 | rows.Scan(&out) |
| 481 | if out != 5 { |
| 482 | dbt.Errorf("expected 5, got %d", out) |
| 483 | } |
| 484 | |
| 485 | if rows.Next() { |
| 486 | dbt.Error("unexpected data") |
| 487 | } |
| 488 | } else { |
| 489 | dbt.Error("no data") |
| 490 | } |
| 491 | rows.Close() |
| 492 | |
| 493 | }) |
| 494 | } |
| 495 | |
| 496 | func TestInt(t *testing.T) { |
| 497 | runTestsParallel(t, dsn, func(dbt *DBTest, tbl string) { |
nothing calls this directly
no test coverage detected