Skip to content

Commit

Permalink
support mysql-for-test (#16)
Browse files Browse the repository at this point in the history
* support mysql-for-test

* move shell to package.json
  • Loading branch information
Chyroc-MD authored Jan 14, 2017
1 parent 363146c commit aded355
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 3 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ sudo: required

services:
- docker
- mysql

language: node_js

Expand All @@ -15,4 +16,5 @@ before_install:
- docker run -d -p 12000:12000 jimexist/sqoop:1.99.7-2

script:
npm run coverage
- echo "USE mysql;\nUPDATE user SET password=PASSWORD('1234') WHERE user='root';\nFLUSH PRIVILEGES;\n" | mysql -u root
- npm run coverage
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
42 changes: 42 additions & 0 deletions test/init.sql
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit aded355

Please sign in to comment.