From 23806b0db11ce49dc836d379a531aee355c401c4 Mon Sep 17 00:00:00 2001 From: Nuno Cruces Date: Thu, 16 Feb 2023 13:58:53 +0000 Subject: [PATCH] More tests. --- conn_test.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/conn_test.go b/conn_test.go index e7b8ded..b3eec7b 100644 --- a/conn_test.go +++ b/conn_test.go @@ -2,6 +2,7 @@ package sqlite3 import ( "bytes" + "context" "errors" "math" "testing" @@ -50,6 +51,17 @@ func TestConn_SetInterrupt(t *testing.T) { } defer db.Close() + ctx, cancel := context.WithCancel(context.TODO()) + db.SetInterrupt(ctx.Done()) + + // Interrupt doesn't interrupt this. + err = db.Exec(`SELECT 1`) + if err != nil { + t.Fatal(err) + } + + db.SetInterrupt(nil) + stmt, _, err := db.Prepare(` WITH RECURSIVE fibonacci (curr, next) @@ -66,9 +78,8 @@ func TestConn_SetInterrupt(t *testing.T) { } defer stmt.Close() - done := make(chan struct{}) - close(done) - db.SetInterrupt(done) + cancel() + db.SetInterrupt(ctx.Done()) var serr *Error