[FEAT] Mark database errors in tests as failure
- If the database returns a error in integration tests, it should be marked as a failure of the test. - Ref: https://codeberg.org/forgejo/forgejo/issues/2962 (this should help with logging the SQL that is resulting in the error).
This commit is contained in:
parent
68e900822b
commit
2dabd202ce
|
@ -155,8 +155,14 @@ func InitEngine(ctx context.Context) error {
|
||||||
Logger: log.GetLogger("xorm"),
|
Logger: log.GetLogger("xorm"),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
errorLogger := log.GetLogger("xorm")
|
||||||
|
if setting.IsInTesting {
|
||||||
|
errorLogger = log.GetLogger(log.DEFAULT)
|
||||||
|
}
|
||||||
|
|
||||||
xormEngine.AddHook(&ErrorQueryHook{
|
xormEngine.AddHook(&ErrorQueryHook{
|
||||||
Logger: log.GetLogger("xorm"),
|
Logger: errorLogger,
|
||||||
})
|
})
|
||||||
|
|
||||||
SetDefaultEngine(ctx, xormEngine)
|
SetDefaultEngine(ctx, xormEngine)
|
||||||
|
|
|
@ -393,6 +393,9 @@ var ignoredErrorMessage = []string{
|
||||||
|
|
||||||
// TestRenameInvalidUsername
|
// TestRenameInvalidUsername
|
||||||
`TrString() [E] Missing translation "form.Name"`,
|
`TrString() [E] Missing translation "form.Name"`,
|
||||||
|
|
||||||
|
// TestDatabaseCollation
|
||||||
|
`[E] [Error SQL Query] INSERT INTO test_collation_tbl (txt) VALUES ('main') []`,
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *testLoggerWriterCloser) recordError(msg string) {
|
func (w *testLoggerWriterCloser) recordError(msg string) {
|
||||||
|
|
Loading…
Reference in a new issue