Documentation ¶
Overview ¶
Debug SQL transactions inside tests
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Open ¶
Example ¶
// dummy database setup db, err := sql.Open("postgres", "postgres://127.0.0.1/template1") if err != nil { log.Fatal(err) } tx, err := db.Begin() if err != nil { log.Fatal(err) } defer tx.Rollback() Open(tx)
Output:
func OpenWithQuery ¶
Example ¶
// dummy database setup db, err := sql.Open("postgres", "postgres://127.0.0.1/template1") if err != nil { log.Fatal(err) } tx, err := db.Begin() if err != nil { log.Fatal(err) } defer tx.Rollback() OpenWithQuery(tx, "SELECT count(1) FROM users") // starts with this query as "default"
Output:
func StartServer ¶
StartServer starts a new http server for the given transaction
The server shuts down when a) the user presses the "quit" button or b) on the first db error (as we can not recover from that error inside the transaction)
Example ¶
// dummy database setup db, err := sql.Open("postgres", "postgres://127.0.0.1/template1") if err != nil { log.Fatal(err) } tx, err := db.Begin() if err != nil { log.Fatal(err) } defer tx.Rollback() waitForClose, addr := StartServer(tx, "") openURL(addr) <-waitForClose // blocks until the QUIT button is pressed or first error occurs on tx
Output:
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.