An open API service indexing awesome lists of open source software.

https://github.com/hfm/mruby-test-mysqld

Setting up a mysqld instance in tmpdir, and destroying it when a mruby program exits.
https://github.com/hfm/mruby-test-mysqld

mruby mysql test test-mysqld

Last synced: 28 days ago
JSON representation

Setting up a mysqld instance in tmpdir, and destroying it when a mruby program exits.

Awesome Lists containing this project

README

          

# mruby-test-mysqld [![Build Status](https://travis-ci.org/hfm/mruby-test-mysqld.svg?branch=master)](https://travis-ci.org/hfm/mruby-test-mysqld)

Setting up a mysqld instance in tmpdir, and destroying it when a mruby program exits. The aim for this project is a port of [Test::mysqld](http://search.cpan.org/~kazuho/Test-mysqld/) to [mruby](https://github.com/mruby/mruby).

## install by mrbgems

- add conf.gem line to `build_config.rb`

```ruby
MRuby::Build.new do |conf|

# ... (snip) ...

conf.gem :github => 'hfm/mruby-test-mysqld'
end
```

## example

```ruby
mysqld = TestMysqld.new
# ... Initialize mysqld ...
# ... Starting mysqld ...
# => #"/tmp/mruby_testmysqld_1472791284/tmp/mysql.sock", :datadir=>"/tmp/mruby_testmysqld_1472791284/var", :pid_file=>"/tmp/mruby_testmysqld_1472791284/tmp/mysqld.pid"}, @base_dir="/tmp/mruby_testmysqld_1472791284", @mysqld="/usr/local/bin/mysqld">

db = MySQL::Database.new 'localhost', 'root', '', 'test', 3306, mysqld.socket
# => #>
# ... Execute db query...

db.close
# => nil

mysqld.stop
# ... Shutting down mysqld ...
# => nil
```

## License

under the MIT License:
- see [LICENSE](./LICENSE) file