Skip to content

Commit

Permalink
test: add unit/integration tests
Browse files Browse the repository at this point in the history
chore: add ci config and test fixtures

fix: hard-coded environment property in Base unit test

fix: tests timeout on ci server

fix: wrong build task for tests in gulpfile

fix: add stdout and stderr listeners to debug test on ci server

fix: shebang line not finding node on linux (#32)

chore: bump lux up to the latest release in the test-app

fix: increase sleep interval before running tests

fix: increase sleep interval again

fix: decrease sleep interval and stop testing node 4.x for now

fix: listening message dispatched before workers are ready (#34)

chore: Link to Medium Article in Readme (#33)

feat: add pagination to controller integration test

fix: sql dump syntax error

fix: wrong sql dump :P

feat: test against node 4 as well as 5

fix: increase mocha timeout time

Node 4 works locally just takes longer to boot.

feat: more integration testing

fix: logger date incorrect (#35)

Merge pull request #36 from postlight/database-missing-port

fix: missing port in database config generation

chore: bump version to 0.0.1-beta.3 (#37)
  • Loading branch information
zacharygolba committed Apr 20, 2016
1 parent 4a193b8 commit 79cfb57
Show file tree
Hide file tree
Showing 44 changed files with 1,223 additions and 17 deletions.
3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ gulpfile.babel.js
# logs
/log
npm-debug.log

# tests
/test
15 changes: 15 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
language: node_js

node_js:
- "5"

services:
- mysql

before_script:
- cat test/fixtures/data.sql | mysql -u travis
- npm install -g gulp
- npm install -g lux-framework

env:
- NODE_ENV="test"
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ A MVC style framework for building highly performant, large scale JSON APIs that

This isn't another wrapper around [Express](http://expressjs.com/) or a framework for building frameworks. This also isn't a replacement for server-side frameworks that render DHTML.

[Check out the Medium Article!](https://trackchanges.postlight.com/not-another-node-js-framework-33103ebeedf8)

## What?

### Features
Expand Down
2 changes: 1 addition & 1 deletion bin/lux
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env node --use_strict
#!/usr/bin/env node
require('../dist/packages/cli');
2 changes: 1 addition & 1 deletion examples/social-network/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"author": "",
"license": "MIT",
"dependencies": {
"lux-framework": "0.0.1-beta",
"lux-framework": "0.0.1-beta.3",
"babel-core": "6.7.4",
"babel-eslint": "6.0.2",
"babel-plugin-transform-decorators-legacy": "1.3.4",
Expand Down
2 changes: 1 addition & 1 deletion examples/todo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"author": "",
"license": "MIT",
"dependencies": {
"lux-framework": "0.0.1-beta",
"lux-framework": "0.0.1-beta.3",
"babel-core": "6.7.4",
"babel-eslint": "6.0.2",
"babel-plugin-transform-decorators-legacy": "1.3.4",
Expand Down
29 changes: 28 additions & 1 deletion gulpfile.babel.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import gulp from 'gulp';
import babel from 'gulp-babel';
import mocha from 'gulp-mocha';
import eslint from 'gulp-eslint';
import uglify from 'gulp-uglify';

import exec from './src/packages/cli/utils/exec';
import rmrf from './src/packages/cli/utils/rmrf';

gulp.task('clean', () => {
Expand All @@ -16,11 +18,36 @@ gulp.task('build', ['lint', 'clean'], () => {
.pipe(gulp.dest('dist'));
});

gulp.task('build:test', ['build'], () => {
return exec('npm install', {
cwd: `${__dirname}/test/test-app`
});
});

gulp.task('lint', () => {
return gulp.src('src/**/*.js')
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});

gulp.task('default', ['lint']);
gulp.task('test', ['build:test'], () => {
return gulp.src([
'test/helper.js',
'test/unit/**/*.js',
'test/integration/**/*.js'
], { read: false })
.pipe(
mocha({
bail: true,
timeout: 600000,
require: [
'babel-core/register'
]
})
)
.once('error', () => process.exit(1))
.once('end', () => process.exit());
});

gulp.task('default', ['build']);
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lux-framework",
"version": "0.0.1-beta",
"version": "0.0.1-beta.3",
"description": "A MVC style Node.js framework for building lightning fast JSON APIs",
"repository": "https://github.com/postlight/lux",
"main": "dist/index.js",
Expand All @@ -9,10 +9,13 @@
},
"scripts": {
"start": "lux serve",
"test": "lux test"
"test": "gulp test"
},
"author": "Zachary Golba",
"license": "MIT",
"engines": {
"node": ">= 4.0"
},
"dependencies": {
"ansi-regex": "2.0.0",
"babel-runtime": "6.6.1",
Expand All @@ -30,11 +33,15 @@
"babel-plugin-transform-runtime": "6.6.0",
"babel-preset-es2015": "6.6.0",
"babel-preset-stage-1": "6.5.0",
"chai": "3.5.0",
"eslint": "2.7.0",
"gulp": "3.9.1",
"gulp-babel": "6.1.2",
"gulp-eslint": "2.0.0",
"gulp-mocha": "2.2.0",
"gulp-uglify": "1.5.3",
"isomorphic-fetch": "2.2.1",
"mocha": "2.4.5",
"mysql": "2.10.2"
}
}
5 changes: 3 additions & 2 deletions src/packages/application/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Application extends Base {
}

async boot() {
const { root, router, domain } = this;
const { root, router, domain, server, port } = this;
const store = Database.create(
require(`${root}/config/database.json`)
);
Expand Down Expand Up @@ -133,7 +133,8 @@ class Application extends Base {

routes.get('routes').call(null, router.route, router.resource);

this.server.listen(this.port);
server.instance.once('listening', () => process.send('ready'));
server.listen(port);

return this;
}
Expand Down
18 changes: 12 additions & 6 deletions src/packages/cli/commands/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,24 @@ export default async function serve(port = 4000) {
const Application = require(`${pwd}/bin/app`);
const config = require(`${pwd}/config/environments/${env}.json`);
const logger = await Logger.create();
let workers = 0;

if (config.port) {
port = config.port;
}

if (cluster.isMaster) {
for (var i = 0; i < os.cpus().length; i++) {
cluster.fork().once('online', () => {
workers++;
if (i === workers) {
logger.log(`Lux Server listening on port ${cyan(`${port}`)}`);
const total = os.cpus().length;
let current = 0;

logger.log(`Starting Lux Server with ${cyan(`${total}`)} worker processes`);

for (let i = 0; i < total; i++) {
cluster.fork().once('message', msg => {
if (msg === 'ready') {
current++;
if (current === total) {
logger.log(`Lux Server listening on port ${cyan(`${port}`)}`);
}
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/packages/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import generate from './commands/generate';

import tryCatch from '../../utils/try-catch';

cli.version('0.0.1-beta');
cli.version('0.0.1-beta.3');

cli
.command('n <name>')
Expand Down
3 changes: 3 additions & 0 deletions src/packages/cli/templates/database-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export default (name) => {
"password": "root",
"database": "${name}_dev",
"host": "127.0.0.1",
"port": "3306",
"dialect": "mysql",
"logging": false
},
Expand All @@ -16,6 +17,7 @@ export default (name) => {
"password": "root",
"database": "${name}_test",
"host": "127.0.0.1",
"port": "3306",
"dialect": "mysql",
"logging": false
},
Expand All @@ -24,6 +26,7 @@ export default (name) => {
"password": "root",
"database": "${name}_prod",
"host": "127.0.0.1",
"port": "3306",
"dialect": "mysql",
"logging": false
}
Expand Down
2 changes: 1 addition & 1 deletion src/packages/cli/templates/package-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default (name) => {
"author": "",
"license": "MIT",
"dependencies": {
"lux-framework": "0.0.1-beta",
"lux-framework": "0.0.1-beta.3",
"babel-core": "6.7.4",
"babel-eslint": "6.0.2",
"babel-plugin-transform-decorators-legacy": "1.3.4",
Expand Down
2 changes: 1 addition & 1 deletion src/packages/logger/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Logger extends Base {
}

get timestamp() {
return moment().format('M/d/YY h:m:ss A');
return moment().format('M/D/YY h:m:ss A');
}

@bound
Expand Down
85 changes: 85 additions & 0 deletions test/fixtures/data.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
DROP DATABASE IF EXISTS `lux_test`;
CREATE DATABASE `lux_test` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `lux_test`;
-- MySQL dump 10.13 Distrib 5.6.24, for osx10.8 (x86_64)
--
-- Host: 127.0.0.1 Database: lux_test
-- ------------------------------------------------------
-- Server version 5.7.11

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Table structure for table `author`
--

DROP TABLE IF EXISTS `author`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `author` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`created_at` datetime DEFAULT NULL,
`updated_at` datetime DEFAULT NULL,
`name` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `author`
--

LOCK TABLES `author` WRITE;
/*!40000 ALTER TABLE `author` DISABLE KEYS */;
INSERT INTO `author` VALUES (1,'2016-04-16 19:02:28','2016-04-16 19:02:28','New Author 1'),(2,'2016-04-16 19:02:31','2016-04-16 19:02:31','New Author 2');
/*!40000 ALTER TABLE `author` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `post`
--

DROP TABLE IF EXISTS `post`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `post` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`created_at` datetime DEFAULT NULL,
`updated_at` datetime DEFAULT NULL,
`title` varchar(255) DEFAULT NULL,
`body` varchar(255) DEFAULT NULL,
`is_public` tinyint(1) DEFAULT '0',
`author_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=52 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `post`
--

LOCK TABLES `post` WRITE;
/*!40000 ALTER TABLE `post` DISABLE KEYS */;
INSERT INTO `post` VALUES (1,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 1','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,1),(2,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 2','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,1),(3,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 5','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,1),(4,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 3','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,1),(5,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 6','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,1),(6,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 4','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,1),(7,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 7','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,1),(8,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 12','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,1),(9,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 11','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,1),(10,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 10','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,1),(11,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 8','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,1),(12,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 9','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,1),(13,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 13','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,1),(14,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 14','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,1),(15,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 15','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,1),(16,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 17','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,1),(17,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 16','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,1),(18,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 19','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,1),(19,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 18','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,1),(20,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 20','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,1),(21,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 23','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,1),(22,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 22','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,1),(23,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 21','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,1),(24,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 24','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,1),(25,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 25','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,1),(26,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 26','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,2),(27,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 27','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,2),(28,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 29','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,2),(29,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 28','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,2),(30,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 31','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,2),(31,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 30','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,2),(32,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 34','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,2),(33,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 35','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,2),(34,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 32','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,2),(35,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 33','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,2),(36,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 36','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,2),(37,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 39','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,2),(38,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 40','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,2),(39,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 41','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,2),(40,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 37','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,2),(41,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 38','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,2),(42,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 42','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,2),(43,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 43','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,2),(44,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 48','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,2),(45,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 46','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,2),(46,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 45','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,2),(47,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 44','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,2),(48,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 47','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,2),(49,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 49','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,2),(50,'2016-04-16 19:00:53','2016-04-16 19:10:04','New Post 50','Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',1,2);
/*!40000 ALTER TABLE `post` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2016-04-18 18:20:06
43 changes: 43 additions & 0 deletions test/helper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import os from 'os';
import path from 'path';
import { spawn } from 'child_process';

import Promise from 'bluebird';

let app;

before(done => {
const testApp = path.join(__dirname, 'test-app');

app = spawn('lux', ['serve'], {
cwd: testApp,
env: {
...process.env,
PWD: testApp
}
});

app.once('error', done);

app.stdout.setEncoding('utf8');
app.stderr.setEncoding('utf8');

app.stdout.on('data', data => {
const isListening = /^.+listening\son\sport\s\d+\n$/g.test(data);

if (isListening) {
done();
}
});

app.stderr.once('data', err => {
err = new Error(err);
done(err);
});
});

after(() => {
if (app) {
app.kill();
}
});
Loading

0 comments on commit 79cfb57

Please sign in to comment.