blackbeam / rust-mysql-simple

Mysql client library implemented in rust.
Apache License 2.0
659 stars 144 forks source link

Augment testing with an in-process MySQL server #126

Open jonhoo opened 6 years ago

jonhoo commented 6 years ago

Over the past couple of days, I've written up a library for emulating a MySQL server. It essentially implements the "other side" of the MySQL network protocol, and delegates handling of queries to a user-defined backend (also implemented in Rust). I found the mysql crate super helpful in working out its kinks, and I re-use code from mysql_common wherever possible.

The crate works fairly well at this point, and even self-tests by using this crate to connect to itself, and then running a bunch of queries (see tests starting from here). It occurred to me that this might also help test the mysql crate without relying on an externally-running MySQL DB. Feel free to close if you don't think it's a good idea.

0xpr03 commented 6 years ago

Just a note that you probably want to run tests against a real mariadb/mysql instance, to get real-world feedback from all of their quirks.

Kinrany commented 2 years ago

It would be cool to run a query against a real database, save the response, and then use a fake in-process database to run tests without spinning up a real database every time.

Doing this at the driver level means that all higher level libraries like diesel and sqlx can share the implementation.