Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tasks to drop and create test database #188

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ Please note that this project is released with a [Contributor Code of Conduct](C
0. Build it and make sure the tests pass on your machine: `script/cibuild`. It will run both trilogy and ruby bindings suites in docker environment.

To shorten the development loop you can:

> [!TIP]
> If you haven't already, you will need to create a database named `test`.

a) run trilogy tests locally with: `make test`
b) run ruby binding tests with `cd contrib/ruby`, `bundle exec rake test`. It's possible to run a test single example by passing a `TESTOPTS` environment variable like so: `TESTOPTS=-n/test_packet_size_greater_than_trilogy_max_packet_len/`.
Expand Down
17 changes: 16 additions & 1 deletion contrib/ruby/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,25 @@ Rake::TestTask.new do |t|
t.test_files = FileList['test/*_test.rb']
t.verbose = true
end
task :test => :compile

task :test => [:compile, "db:clean"]

task :default => :test

task :console => :compile do
sh "ruby -I lib -r trilogy -S irb"
end

namespace :db do
task :create do
mysql_command = "mysql -uroot -e"
%x( #{mysql_command} "create DATABASE IF NOT EXISTS test DEFAULT CHARACTER SET utf8mb4" )
end

task :drop do
mysql_command = "mysql -uroot -e"
%x( #{mysql_command} "drop DATABASE IF EXISTS test" )
end

task :clean => ["db:drop", "db:create"]
end
Loading