diff --git a/.travis.yml b/.travis.yml index 3f43c36..49d2a6a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,7 @@ sudo: required services: - docker + - mysql language: node_js @@ -15,4 +16,5 @@ before_install: - 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 + - 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/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