Skip to content
This repository has been archived by the owner on May 31, 2024. It is now read-only.

Commit

Permalink
Merge pull request #22 from codenize-tools/fix_spec
Browse files Browse the repository at this point in the history
Fix spec
  • Loading branch information
winebarrel committed Oct 14, 2018
2 parents 79ab681 + a45ae41 commit f3044ed
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 32 deletions.
31 changes: 18 additions & 13 deletions .travis.yml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4,20 +4,25 @@ rvm:
- 2.3 - 2.3
- 2.4 - 2.4
- 2.5 - 2.5
cache:
- bundler
- apt
env: env:
- MYSQL_VERSION=mysql-5.6 matrix:
- MYSQL_VERSION=mysql-5.7 - MYSQ_PORT=14406 # MySQL 5.6
matrix: - MYSQ_PORT=14407 # MySQL 5.7
allow_failures:
- env: MYSQL_VERSION=mysql-5.7
services:
- mysql
before_install:
- gem update bundler
- sudo apt-get -qq update
- bash .travis/install_mysql.sh
before_script: before_script:
- mysql --version - sudo service mysql stop
script:
- bundle install - bundle install
- docker-compose up -d
- function mysql_ping { mysqladmin -u root -h 127.0.0.1 -P $MYSQ_PORT ping; }
- for i in {1..60}; do mysql_ping && break; sleep 1; done
script:
- bundle exec rake - bundle exec rake
services:
- docker
addons:
apt:
packages:
- mysql-client-core-5.6
- mysql-client-5.6
16 changes: 0 additions & 16 deletions .travis/install_mysql.sh

This file was deleted.

11 changes: 10 additions & 1 deletion README.md
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Usage: gratan [options]
-h, --help -h, --help
``` ```


A default connection to a database can be established by setting the following environment variables: A default connection to a database can be established by setting the following environment variables:
- `GRATAN_DB_HOST`: database host - `GRATAN_DB_HOST`: database host
- `GRATAN_DB_PORT`: database port - `GRATAN_DB_PORT`: database port
- `GRATAN_DB_SOCKET`: database socket - `GRATAN_DB_SOCKET`: database socket
Expand Down Expand Up @@ -136,6 +136,15 @@ user 'scott', 'localhost', identified: 'tiger' do
end end
``` ```


## Run tests

```sh
bundle install
docker-compose up -d
bundle exec rake
#MYSQL_PORT=14407 bundle exec rake # MySQL 5.7
```

## Similar tools ## Similar tools
* [Codenize.tools](http://codenize.tools/) * [Codenize.tools](http://codenize.tools/)


Expand Down
12 changes: 12 additions & 0 deletions docker-compose.yml
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,12 @@
mysql56:
image: "mysql:5.6"
ports:
- "14406:3306"
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
mysql57:
image: "mysql:5.6"
ports:
- "14407:3306"
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
5 changes: 3 additions & 2 deletions spec/spec_helper.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def mysql
retval = nil retval = nil


begin begin
client = Mysql2::Client.new(host: 'localhost', username: 'root') client = Mysql2::Client.new(host: '127.0.0.1', username: 'root', port: ENV.fetch('MYSQL_PORT', 14406))
retval = yield(client) retval = yield(client)
ensure ensure
client.close if client client.close if client
Expand Down Expand Up @@ -139,8 +139,9 @@ def client(user_options = {})
end end


options = { options = {
host: 'localhost', host: '127.0.0.1',
username: 'root', username: 'root',
port: ENV.fetch('MYSQL_PORT', 14406),
ignore_user: IGNORE_USER, ignore_user: IGNORE_USER,
logger: Logger.new('/dev/null'), logger: Logger.new('/dev/null'),
} }
Expand Down

0 comments on commit f3044ed

Please sign in to comment.