Fix flake.

This commit is contained in:
Nuno Cruces
2025-04-08 12:41:46 +01:00
parent 73ac7e06f6
commit 1b0bf3495e
3 changed files with 7 additions and 5 deletions

View File

@@ -248,8 +248,9 @@ func Test_nested_context(t *testing.T) {
want(inner, 0)
cancel()
if inner.Next() || !errors.Is(inner.Err(), sqlite3.INTERRUPT) {
t.Fatal(inner.Err())
var terr interface{ Temporary() bool }
if inner.Next() || !errors.As(inner.Err(), &terr) || !terr.Temporary() {
t.Fatalf("got %v, want temporary", inner.Err())
}
want(outer, 1)

View File

@@ -75,7 +75,7 @@ func (e *Error) As(err any) bool {
// Temporary returns true for [BUSY] errors.
func (e *Error) Temporary() bool {
return e.Code() == BUSY
return e.Code() == BUSY || e.Code() == INTERRUPT
}
// Timeout returns true for [BUSY_TIMEOUT] errors.

View File

@@ -287,8 +287,9 @@ func TestConn_Transaction_busy(t *testing.T) {
go cancel()
_, err = db2.BeginExclusive()
if !errors.Is(err, sqlite3.BUSY) && !errors.Is(err, sqlite3.INTERRUPT) {
t.Errorf("got %v, want sqlite3.BUSY or sqlite3.INTERRUPT", err)
var terr interface{ Temporary() bool }
if !errors.As(err, &terr) || !terr.Temporary() {
t.Errorf("got %v, want temporary", err)
}
err = nil