mirror of
https://github.com/ncruces/go-sqlite3.git
synced 2026-01-11 21:49:13 +00:00
Fix flake.
This commit is contained in:
@@ -248,8 +248,9 @@ func Test_nested_context(t *testing.T) {
|
|||||||
want(inner, 0)
|
want(inner, 0)
|
||||||
cancel()
|
cancel()
|
||||||
|
|
||||||
if inner.Next() || !errors.Is(inner.Err(), sqlite3.INTERRUPT) {
|
var terr interface{ Temporary() bool }
|
||||||
t.Fatal(inner.Err())
|
if inner.Next() || !errors.As(inner.Err(), &terr) || !terr.Temporary() {
|
||||||
|
t.Fatalf("got %v, want temporary", inner.Err())
|
||||||
}
|
}
|
||||||
|
|
||||||
want(outer, 1)
|
want(outer, 1)
|
||||||
|
|||||||
2
error.go
2
error.go
@@ -75,7 +75,7 @@ func (e *Error) As(err any) bool {
|
|||||||
|
|
||||||
// Temporary returns true for [BUSY] errors.
|
// Temporary returns true for [BUSY] errors.
|
||||||
func (e *Error) Temporary() bool {
|
func (e *Error) Temporary() bool {
|
||||||
return e.Code() == BUSY
|
return e.Code() == BUSY || e.Code() == INTERRUPT
|
||||||
}
|
}
|
||||||
|
|
||||||
// Timeout returns true for [BUSY_TIMEOUT] errors.
|
// Timeout returns true for [BUSY_TIMEOUT] errors.
|
||||||
|
|||||||
@@ -287,8 +287,9 @@ func TestConn_Transaction_busy(t *testing.T) {
|
|||||||
go cancel()
|
go cancel()
|
||||||
|
|
||||||
_, err = db2.BeginExclusive()
|
_, err = db2.BeginExclusive()
|
||||||
if !errors.Is(err, sqlite3.BUSY) && !errors.Is(err, sqlite3.INTERRUPT) {
|
var terr interface{ Temporary() bool }
|
||||||
t.Errorf("got %v, want sqlite3.BUSY or sqlite3.INTERRUPT", err)
|
if !errors.As(err, &terr) || !terr.Temporary() {
|
||||||
|
t.Errorf("got %v, want temporary", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = nil
|
err = nil
|
||||||
|
|||||||
Reference in New Issue
Block a user