MCPcopy
hub / github.com/rubenv/sql-migrate / TestMigrateTransaction

Method TestMigrateTransaction

migrate_test.go:300–322  ·  view source on GitHub ↗
(c *C)

Source from the content-addressed store, hash-verified

298}
299
300func (s *SqliteMigrateSuite) TestMigrateTransaction(c *C) {
301 migrations := &MemoryMigrationSource{
302 Migrations: []*Migration{
303 sqliteMigrations[0],
304 sqliteMigrations[1],
305 {
306 Id: "125",
307 Up: []string{"INSERT INTO people (id, first_name) VALUES (1, 'Test')", "SELECT fail"},
308 Down: []string{}, // Not important here
309 },
310 },
311 }
312
313 // Should fail, transaction should roll back the INSERT.
314 n, err := Exec(s.Db, "sqlite3", migrations, Up)
315 c.Assert(err, Not(IsNil))
316 c.Assert(n, Equals, 2)
317
318 // INSERT should be rolled back
319 count, err := s.DbMap.SelectInt("SELECT COUNT(*) FROM people")
320 c.Assert(err, IsNil)
321 c.Assert(count, Equals, int64(0))
322}
323
324func (s *SqliteMigrateSuite) TestPlanMigration(c *C) {
325 migrations := &MemoryMigrationSource{

Callers

nothing calls this directly

Calls 1

ExecFunction · 0.85

Tested by

no test coverage detected