-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
5,466 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
var apiServer = require('../lib/api-server') | ||
apiServer.init(3420) | ||
console.log('api-server started') | ||
process.on('SIGTERM', function () { | ||
console.log('api-server shutdown') | ||
process.exit(0) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
var docWorker = require('../lib/doc-worker') | ||
docWorker.init('./git-root') | ||
console.log('doc-worker started') | ||
process.on('SIGTERM', function () { | ||
console.log('doc-worker shutdown') | ||
process.exit(0) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,4 +39,5 @@ web-server: | |
restart: always | ||
environment: | ||
- NODE_ENV=dev | ||
- HOST_NAME=192.168.99.100 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
redis: | ||
image: redis | ||
command: redis-server --appendonly yes | ||
ports: | ||
- 6379:6379 | ||
|
||
mongodb: | ||
image: mongo | ||
ports: | ||
- 27017:27017 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* global describe it before beforeEach */ | ||
var assert = require('assert') | ||
var apiServer = require('../lib/api-server') | ||
var request = require('request') | ||
var Bull = require('bull') | ||
var services = require('../lib/services') | ||
var async = require('async') | ||
var path = require('path') | ||
var fs = require('fs') | ||
|
||
var replayGitHubEvent = function (eventDir, done) { | ||
var payload = fs.readFileSync(path.join(__dirname, 'fixtures/events', eventDir, 'payload.json')) | ||
var headers = require(path.join(__dirname, 'fixtures/events', eventDir, 'headers.js')) | ||
request({ | ||
url: 'http://localhost:9876/github/callback', | ||
method: headers.method, | ||
body: payload, | ||
headers: headers | ||
}, done) | ||
} | ||
|
||
describe('The api-server module', function () { | ||
this.timeout(4000) | ||
|
||
var inbox | ||
|
||
before(function (done) { | ||
apiServer.init(9876) | ||
inbox = new Bull('inbox', services.redis.port, services.redis.host) | ||
inbox.on('ready', done) | ||
}) | ||
|
||
beforeEach(function (done) { | ||
var cleaners = ['completed', 'waiting', 'delayed', 'failed'].map(function (type) { | ||
return async.asyncify(inbox.clean.bind(inbox, 0, type)) | ||
}) | ||
async.series(cleaners, done) | ||
}) | ||
|
||
it('HTTP POST Push Event to /github/callback created inbox entry', function (done) { | ||
replayGitHubEvent('acme-push', function (err, res) { | ||
assert(!err) | ||
assert.equal(res.statusCode, 200) | ||
setTimeout(function () { | ||
inbox.count() | ||
.then(function (count) { | ||
assert.equal(count, 1) | ||
done() | ||
}) | ||
.catch(done) | ||
}, 300) | ||
}) | ||
}) | ||
|
||
it('HTTP POST Create Event to /github/callback created inbox entry', function (done) { | ||
replayGitHubEvent('acme-tag', function (err, res) { | ||
assert(!err) | ||
assert.equal(res.statusCode, 200) | ||
setTimeout(function () { | ||
inbox.count() | ||
.then(function (count) { | ||
assert.equal(count, 1) | ||
done() | ||
}) | ||
.catch(done) | ||
}, 100) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* global describe it before beforeEach after */ | ||
var assert = require('assert') | ||
var Doclet = require('../lib/models/doclet') | ||
var services = require('../lib/services') | ||
var mongoose = require('mongoose') | ||
var Bull = require('bull') | ||
var fs = require('fs') | ||
var fse = require('fs-extra') | ||
var path = require('path') | ||
var docWorker = require('../lib/doc-worker') | ||
|
||
var loadGitHubEvent = function (eventDir) { | ||
var payload = fs.readFileSync(path.join(__dirname, 'fixtures/events', eventDir, 'payload.json')) | ||
return JSON.parse(payload) | ||
} | ||
|
||
var tmpPath = path.join(__dirname, 'git-temp') | ||
|
||
describe('The doc-worker module', function () { | ||
this.timeout(10000) | ||
var inbox | ||
|
||
before(function (done) { | ||
docWorker.init(tmpPath) | ||
inbox = new Bull('inbox', services.redis.port, services.redis.host) | ||
inbox.on('ready', done) | ||
}) | ||
|
||
after(function (done) { | ||
fse.removeSync(tmpPath) | ||
mongoose.connection.close(done) | ||
}) | ||
|
||
beforeEach(function (done) { | ||
Doclet.remove({}, done) | ||
}) | ||
|
||
it('pushing a push event to the inbox will create a doclet', function (done) { | ||
var event = loadGitHubEvent('acme-push') | ||
inbox.add(event) | ||
setTimeout(function () { | ||
Doclet.findById('lipp/acme-jsdoc-example/master', function (err, doclet) { | ||
if (err) { | ||
done(err) | ||
} else { | ||
assert(doclet) | ||
inbox.count().then(function (count) { | ||
assert.equal(count, 0) | ||
done() | ||
}) | ||
} | ||
}) | ||
}, 3000) | ||
}) | ||
|
||
it('pushing a push event to the inbox will create a doclet', function (done) { | ||
var event = loadGitHubEvent('acme-push') | ||
inbox.add(event) | ||
setTimeout(function () { | ||
Doclet.findById('lipp/acme-jsdoc-example/master', function (err, doclet) { | ||
if (err) { | ||
done(err) | ||
} else { | ||
assert(doclet) | ||
inbox.count().then(function (count) { | ||
assert.equal(count, 0) | ||
done() | ||
}) | ||
} | ||
}) | ||
}, 3000) | ||
}) | ||
}) |
Oops, something went wrong.