Running unit-tests with MySQL

Bonjour,

It would be worth running the unit tests with MySQL and not just SQLite. The idea is not new, @lunny created a pull request to that end in 2019 and closed it in 2020, presumably because there was not much interest. I wonder how difficult it would be?

My motivation is that I ran into this error while running the MySQL integration tests:

$ go test  -c code.gitea.io/gitea/models/migrations -o migrations.individual.mysql8.test
...
[test-mysql8:65]     testlogger.go:78: 2021/10/29 19:40:45 ...ctivitypub/person.go:103:Person() [E] GetPublicKey: Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key IN (?) ORDER BY `id` ASC' at line 1

The code triggering the error is from @techknowlogick pull request to introduce user settings in the database and was coincidentally noted by a reviewer a few hours ago with the following comment:

Maybe SettingKey and SettingValue are better, since Key and Value all seem to be possible SQL keywords

And indeed Key is a reserved MySQL keyword, hence the error.

What do you think?

1 Like

I like the idea. I will reopen my PR again. Just sent another PR Support more database types on unit tests by lunny · Pull Request #17545 · go-gitea/gitea · GitHub

1 Like