File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -75,9 +75,11 @@ func (s *SqlHandler) Query(args []driver.Value) (driver.Rows, error) {
75
75
time .Sleep (time .Duration (s .Opts .QueryDelay * int (time .Second ))) // simulate a query delay
76
76
}
77
77
s .row = 0
78
- if s .Opts .QueryError != nil {
78
+ // only show the error if we have not exceeded the fail times and the error is not nil
79
+ if s .Opts .QueryError != nil && (s .Opts .QueryFailTimes == 0 || s .State .QueryAttempts <= s .Opts .QueryFailTimes ) {
79
80
return s , s .Opts .QueryError
80
81
}
82
+
81
83
return s , nil
82
84
}
83
85
@@ -148,10 +150,11 @@ func (s TestDS) Open() (*sql.DB, error) {
148
150
149
151
// DriverOpts the optional settings
150
152
type DriverOpts struct {
151
- ConnectDelay int
152
- QueryDelay int
153
- ConnectError error
154
- QueryError error
153
+ ConnectDelay int
154
+ QueryDelay int
155
+ ConnectError error
156
+ QueryError error
157
+ QueryFailTimes int
155
158
}
156
159
157
160
// State is the state of the connections/queries
You can’t perform that action at this time.
0 commit comments