Commit f99eac24 authored by gwenn's avatar gwenn

Add Interrupt test.

parent 19b7087a
...@@ -8,22 +8,26 @@ import ( ...@@ -8,22 +8,26 @@ import (
"time" "time"
) )
/*
func TestInterrupt(t *testing.T) { func TestInterrupt(t *testing.T) {
db := open(t) db := open(t)
defer db.Close() defer db.Close()
db.CreateScalarFunction("interrupt", 0, nil, func(ctx *Context, nArg int) { db.CreateScalarFunction("interrupt", 0, nil, func(ctx *Context, nArg int) {
//db.Interrupt() db.Interrupt()
ctx.ResultText("ok") ctx.ResultText("ok")
}, nil) }, nil)
var err error s, err := db.Prepare("SELECT interrupt() FROM (SELECT 1 UNION SELECT 2 UNION SELECT 3)")
var result string checkNoError(t, err, "couldn't prepare stmt: %#v")
err = db.OneValue("select interrupt()", &result) defer s.Finalize()
if err == nil || err != ErrInterrupt { err = s.Select(func(s *Stmt) (err error) {
return
})
if err == nil {
t.Fatalf("Expected interrupt but got %v", err)
}
if se, ok := err.(*StmtError); !ok || se.Code() != ErrInterrupt {
t.Errorf("Expected interrupt but got %#v", err) t.Errorf("Expected interrupt but got %#v", err)
} }
} }
*/
func openTwoConnSameDb(t *testing.T) (*os.File, *Conn, *Conn) { func openTwoConnSameDb(t *testing.T) (*os.File, *Conn, *Conn) {
f, err := ioutil.TempFile("", "gosqlite-test") f, err := ioutil.TempFile("", "gosqlite-test")
......
...@@ -70,9 +70,9 @@ func TestTransaction(t *testing.T) { ...@@ -70,9 +70,9 @@ func TestTransaction(t *testing.T) {
db := open(t) db := open(t)
defer db.Close() defer db.Close()
checkNoError(t, db.Begin(), "Error while beginning transaction: %s") checkNoError(t, db.Begin(), "Error while beginning transaction: %s")
/*if err := db.Begin(); err == nil { if err := db.Begin(); err == nil {
t.Fatalf("Error expected (transaction cannot be nested)") t.Fatalf("Error expected (transaction cannot be nested)")
}*/ }
checkNoError(t, db.Commit(), "Error while commiting transaction: %s") checkNoError(t, db.Commit(), "Error while commiting transaction: %s")
} }
......
...@@ -7,7 +7,7 @@ import ( ...@@ -7,7 +7,7 @@ import (
) )
func init() { func init() {
ConfigLog(log, "LOG") //ConfigLog(log, "LOG")
} }
func trace(d interface{}, sql string) { func trace(d interface{}, sql string) {
...@@ -75,5 +75,5 @@ func TestTrace(t *testing.T) { ...@@ -75,5 +75,5 @@ func TestTrace(t *testing.T) {
} }
func TestLog(t *testing.T) { func TestLog(t *testing.T) {
//Log(0, "One message") Log(0, "One message")
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment