From a6f20f7708e97aa4eae87357f55be56f4828ecd5 Mon Sep 17 00:00:00 2001 From: Chyroc Chen Date: Sat, 14 Jan 2017 15:36:44 +0800 Subject: [PATCH 1/4] support mysql-for-test --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3f43c36..22ae57f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,8 @@ node_js: - "4" before_install: - - docker run -d -p 12000:12000 jimexist/sqoop:1.99.7-2 + - docker run --name mysql-for-test -e MYSQL_ROOT_PASSWORD=12345678 -d mysql + - docker run --name sqoop-for-test --link mysql-for-test:mysql -d -p 12000:12000 jimexist/sqoop:1.99.7-2 script: npm run coverage \ No newline at end of file From a5cf33664e8215b4529de8e013ec61be967eff26 Mon Sep 17 00:00:00 2001 From: Chyroc Chen Date: Sat, 14 Jan 2017 18:24:22 +0800 Subject: [PATCH 2/4] mysql shell --- .travis.yml | 8 +++++--- test/dependencies.sh | 46 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 3 deletions(-) create mode 100755 test/dependencies.sh diff --git a/.travis.yml b/.travis.yml index 22ae57f..0e9ab86 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,7 @@ sudo: required services: - docker + - mysql language: node_js @@ -12,8 +13,9 @@ node_js: - "4" before_install: - - docker run --name mysql-for-test -e MYSQL_ROOT_PASSWORD=12345678 -d mysql - - docker run --name sqoop-for-test --link mysql-for-test:mysql -d -p 12000:12000 jimexist/sqoop:1.99.7-2 + - docker run -d -p 12000:12000 jimexist/sqoop:1.99.7-2 script: - npm run coverage \ No newline at end of file + - echo "USE mysql;\nUPDATE user SET password=PASSWORD('1234') WHERE user='root';\nFLUSH PRIVILEGES;\n" | mysql -u root + - test/dependencies.sh + - npm run coverage \ No newline at end of file diff --git a/test/dependencies.sh b/test/dependencies.sh new file mode 100755 index 0000000..565c874 --- /dev/null +++ b/test/dependencies.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +mysql -uroot -p1234 -e " + drop database if exists harry; + create database harry; + + use harry; + + create table books ( + id int not null AUTO_INCREMENT, + title varchar(100), + author varchar(100), + primary key ( id ) + ); + insert into books (title, author) values ('the Sorcerer\'s Stone', 'J. K. Rowling'); + insert into books (title, author) values ('the Chamber of Secrets', 'J. K. Rowling'); + insert into books (title, author) values ('the Prisoner of Azkaban', 'J. K. Rowling'); + insert into books (title, author) values ('the Goblet of Fire', 'J. K. Rowling'); + insert into books (title, author) values ('the Order of the Phoenix', 'J. K. Rowling'); + insert into books (title, author) values ('the Half-Blood Prince', 'J. K. Rowling'); + insert into books (title, author) values ('the Deathly Hallows', 'J. K. Rowling'); + insert into books (title, author) values ('the Cursed Child', 'J. K. Rowling'); + + create table characters ( + id int not null AUTO_INCREMENT, + name varchar(100), + sex int, + primary key ( id ) + ); + insert into characters (name, sex) values ('Albus Dumbledore', 1); + insert into characters (name, sex) values ('Severus Snape', 1); + insert into characters (name, sex) values ('James Potter', 1); + insert into characters (name, sex) values ('Lily Evans', 2); + insert into characters (name, sex) values ('Gellert Grindelwald', 1); + insert into characters (name, sex) values ('Dobby', 3); + insert into characters (name, sex) values ('Cho Chang', 2); + insert into characters (name, sex) values ('Hermione Jean Granger', 2); + insert into characters (name, sex) values ('Harry James Potter', 1); + insert into characters (name, sex) values ('Ronald Bilius Weasley(Ron)', 1); + + + show databases; + use harry; + select * from books; + select * from characters; +" From 49dc56d79f077bd8d31b8a695dd552a3edd98040 Mon Sep 17 00:00:00 2001 From: Chyroc Chen Date: Sat, 14 Jan 2017 18:45:56 +0800 Subject: [PATCH 3/4] move shell to package.json --- .travis.yml | 2 +- package.json | 5 +++-- test/dependencies.sh | 46 -------------------------------------------- test/init.sql | 42 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 46 insertions(+), 49 deletions(-) delete mode 100755 test/dependencies.sh create mode 100755 test/init.sql diff --git a/.travis.yml b/.travis.yml index 0e9ab86..2c23658 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,5 +17,5 @@ before_install: script: - echo "USE mysql;\nUPDATE user SET password=PASSWORD('1234') WHERE user='root';\nFLUSH PRIVILEGES;\n" | mysql -u root - - test/dependencies.sh + - mysql -uroot -p1234 < test/init.sql - npm run coverage \ No newline at end of file diff --git a/package.json b/package.json index 9762bf9..95d5f64 100644 --- a/package.json +++ b/package.json @@ -27,11 +27,12 @@ "prebuild": "npm run lint", "build": "babel -d dist src", "lint": "standard --verbose | snazzy", - "test": "mocha", + "test": "npm run pre-test-mysql && mocha", "precommit": "npm run lint", "prepush": "npm run lint", "prepublish": "npm run clean && npm run build && npm run lint", - "coverage": "nyc npm test && nyc report --reporter=text-lcov | coveralls" + "coverage": "nyc npm test && nyc report --reporter=text-lcov | coveralls", + "pre-test-mysql": "mysql -uroot -p1234 < test/init.sql" }, "dependencies": { "isomorphic-fetch": "^2.2.1" diff --git a/test/dependencies.sh b/test/dependencies.sh deleted file mode 100755 index 565c874..0000000 --- a/test/dependencies.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env bash - -mysql -uroot -p1234 -e " - drop database if exists harry; - create database harry; - - use harry; - - create table books ( - id int not null AUTO_INCREMENT, - title varchar(100), - author varchar(100), - primary key ( id ) - ); - insert into books (title, author) values ('the Sorcerer\'s Stone', 'J. K. Rowling'); - insert into books (title, author) values ('the Chamber of Secrets', 'J. K. Rowling'); - insert into books (title, author) values ('the Prisoner of Azkaban', 'J. K. Rowling'); - insert into books (title, author) values ('the Goblet of Fire', 'J. K. Rowling'); - insert into books (title, author) values ('the Order of the Phoenix', 'J. K. Rowling'); - insert into books (title, author) values ('the Half-Blood Prince', 'J. K. Rowling'); - insert into books (title, author) values ('the Deathly Hallows', 'J. K. Rowling'); - insert into books (title, author) values ('the Cursed Child', 'J. K. Rowling'); - - create table characters ( - id int not null AUTO_INCREMENT, - name varchar(100), - sex int, - primary key ( id ) - ); - insert into characters (name, sex) values ('Albus Dumbledore', 1); - insert into characters (name, sex) values ('Severus Snape', 1); - insert into characters (name, sex) values ('James Potter', 1); - insert into characters (name, sex) values ('Lily Evans', 2); - insert into characters (name, sex) values ('Gellert Grindelwald', 1); - insert into characters (name, sex) values ('Dobby', 3); - insert into characters (name, sex) values ('Cho Chang', 2); - insert into characters (name, sex) values ('Hermione Jean Granger', 2); - insert into characters (name, sex) values ('Harry James Potter', 1); - insert into characters (name, sex) values ('Ronald Bilius Weasley(Ron)', 1); - - - show databases; - use harry; - select * from books; - select * from characters; -" diff --git a/test/init.sql b/test/init.sql new file mode 100755 index 0000000..2e871e4 --- /dev/null +++ b/test/init.sql @@ -0,0 +1,42 @@ +drop database if exists harry; +create database harry; + +use harry; + +create table books ( + id int not null AUTO_INCREMENT, + title varchar(100), + author varchar(100), + primary key (id) +); +insert into books (title, author) values ('the Sorcerer\'s Stone', 'J. K. Rowling'); +insert into books (title, author) values ('the Chamber of Secrets', 'J. K. Rowling'); +insert into books (title, author) values ('the Prisoner of Azkaban', 'J. K. Rowling'); +insert into books (title, author) values ('the Goblet of Fire', 'J. K. Rowling'); +insert into books (title, author) values ('the Order of the Phoenix', 'J. K. Rowling'); +insert into books (title, author) values ('the Half-Blood Prince', 'J. K. Rowling'); +insert into books (title, author) values ('the Deathly Hallows', 'J. K. Rowling'); +insert into books (title, author) values ('the Cursed Child', 'J. K. Rowling'); + +create table characters ( + id int not null AUTO_INCREMENT, + name varchar(100), + sex int, + primary key (id) +); +insert into characters (name, sex) values ('Albus Dumbledore', 1); +insert into characters (name, sex) values ('Severus Snape', 1); +insert into characters (name, sex) values ('James Potter', 1); +insert into characters (name, sex) values ('Lily Evans', 2); +insert into characters (name, sex) values ('Gellert Grindelwald', 1); +insert into characters (name, sex) values ('Dobby', 3); +insert into characters (name, sex) values ('Cho Chang', 2); +insert into characters (name, sex) values ('Hermione Jean Granger', 2); +insert into characters (name, sex) values ('Harry James Potter', 1); +insert into characters (name, sex) values ('Ronald Bilius Weasley(Ron)', 1); + + +show databases; +use harry; +select * from books; +select * from characters; \ No newline at end of file From c9c1ff4a896b9e7923a1cde5c9dfe5c768c4fe7a Mon Sep 17 00:00:00 2001 From: Chyroc Chen Date: Sat, 14 Jan 2017 18:46:50 +0800 Subject: [PATCH 4/4] fix --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2c23658..49d2a6a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,5 +17,4 @@ before_install: script: - echo "USE mysql;\nUPDATE user SET password=PASSWORD('1234') WHERE user='root';\nFLUSH PRIVILEGES;\n" | mysql -u root - - mysql -uroot -p1234 < test/init.sql - npm run coverage \ No newline at end of file