MCPcopy
hub / github.com/rqlite/rqlite / Test_UpdateHook_Tx

Function Test_UpdateHook_Tx

db/db_update_hook_test.go:93–116  ·  view source on GitHub ↗

Test_UpdateHook_Tx demostrates that the Update hook is called for a transaction which is rolled back.

(t *testing.T)

Source from the content-addressed store, hash-verified

91// Test_UpdateHook_Tx demostrates that the Update hook is called for a
92// transaction which is rolled back.
93func 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}

Callers

nothing calls this directly

Calls 8

mustTempPathFunction · 0.85
OpenFunction · 0.85
RegisterUpdateHookMethod · 0.80
WaitMethod · 0.80
mustExecuteFunction · 0.70
RemoveMethod · 0.65
CloseMethod · 0.65
AddMethod · 0.45

Tested by

no test coverage detected