Test_UpdateHook_Tx demostrates that the Update hook is called for a transaction which is rolled back.
(t *testing.T)
| 91 | // Test_UpdateHook_Tx demostrates that the Update hook is called for a |
| 92 | // transaction which is rolled back. |
| 93 | func Test_UpdateHook_Tx(t *testing.T) { |
| 94 | path := mustTempPath() |
| 95 | defer os.Remove(path) |
| 96 | db, err := Open(path, false, false) |
| 97 | if err != nil { |
| 98 | t.Fatalf("error opening database") |
| 99 | } |
| 100 | defer db.Close() |
| 101 | mustExecute(db, "CREATE TABLE foo (id INTEGER PRIMARY KEY, name TEXT)") |
| 102 | |
| 103 | var wg sync.WaitGroup |
| 104 | hook := func(got *command.UpdateHookEvent) error { |
| 105 | defer wg.Done() |
| 106 | return nil |
| 107 | } |
| 108 | if err := db.RegisterUpdateHook(hook); err != nil { |
| 109 | t.Fatalf("error registering update hook") |
| 110 | } |
| 111 | wg.Add(1) |
| 112 | mustExecute(db, "BEGIN") |
| 113 | mustExecute(db, "INSERT INTO foo(id, name) VALUES(1, 'fiona')") |
| 114 | mustExecute(db, "ROLLBACK") |
| 115 | wg.Wait() |
| 116 | } |
nothing calls this directly
no test coverage detected