@@ -84,19 +84,43 @@ func TestDatabase_Deadlock(t *testing.T) {
84
84
db := initTestDB (t )
85
85
ctx := context .Background ()
86
86
_ = db .DoTxn (ctx , nil , func (ctx context.Context ) error {
87
- assert .Panics ( t , func () {
87
+ assert .PanicsWithError ( t , dbutil . ErrQueryDeadlock . Error () , func () {
88
88
_ , _ = db .Exec (context .Background (), "INSERT INTO meow (value) VALUES ('meow 4');" )
89
89
})
90
90
return fmt .Errorf ("meow" )
91
91
})
92
92
}
93
93
94
+ func TestDatabase_Deadlock_Acquire (t * testing.T ) {
95
+ db := initTestDB (t )
96
+ ctx := context .Background ()
97
+ _ = db .DoTxn (ctx , nil , func (ctx context.Context ) error {
98
+ assert .PanicsWithError (t , dbutil .ErrAcquireDeadlock .Error (), func () {
99
+ _ , _ = db .AcquireConn (context .Background ())
100
+ })
101
+ return fmt .Errorf ("meow" )
102
+ })
103
+ }
104
+
105
+ func TestDatabase_Deadlock_Txn (t * testing.T ) {
106
+ db := initTestDB (t )
107
+ ctx := context .Background ()
108
+ _ = db .DoTxn (ctx , nil , func (ctx context.Context ) error {
109
+ assert .PanicsWithError (t , dbutil .ErrTransactionDeadlock .Error (), func () {
110
+ _ = db .DoTxn (context .Background (), nil , func (ctx context.Context ) error {
111
+ return nil
112
+ })
113
+ })
114
+ return fmt .Errorf ("meow" )
115
+ })
116
+ }
117
+
94
118
func TestDatabase_Deadlock_Child (t * testing.T ) {
95
119
db := initTestDB (t )
96
120
ctx := context .Background ()
97
121
childDB := db .Child ("" , nil , nil )
98
122
_ = db .DoTxn (ctx , nil , func (ctx context.Context ) error {
99
- assert .Panics ( t , func () {
123
+ assert .PanicsWithError ( t , dbutil . ErrQueryDeadlock . Error () , func () {
100
124
_ , _ = childDB .Exec (context .Background (), "INSERT INTO meow (value) VALUES ('meow 4');" )
101
125
})
102
126
return fmt .Errorf ("meow" )
@@ -108,7 +132,7 @@ func TestDatabase_Deadlock_Child2(t *testing.T) {
108
132
ctx := context .Background ()
109
133
childDB := db .Child ("" , nil , nil )
110
134
_ = childDB .DoTxn (ctx , nil , func (ctx context.Context ) error {
111
- assert .Panics ( t , func () {
135
+ assert .PanicsWithError ( t , dbutil . ErrQueryDeadlock . Error () , func () {
112
136
_ , _ = db .Exec (context .Background (), "INSERT INTO meow (value) VALUES ('meow 4');" )
113
137
})
114
138
return fmt .Errorf ("meow" )
0 commit comments