Skip to content
This repository has been archived by the owner on Dec 4, 2017. It is now read-only.

Commit

Permalink
Added models
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasmartinelli committed Jan 30, 2015
1 parent aec4a9c commit 003ff36
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 4 deletions.
2 changes: 1 addition & 1 deletion autocomplete.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';
var request = require('request');

exports.find = function(req, res) {

};

17 changes: 17 additions & 0 deletions models.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
var mongoose = require('mongoose');

var repoSchema = new mongoose.Schema({
repo: String,
commits: [{ sha: String}]
});

var commitSchema = new mongoose.Schema({
repo: String,
sha: String,
date: { type: Date, default: Date.now },
flintOutput: [{ file: String, lineno: Number, message: String }],
flintStatus: Number
});

exports.Repo = mongoose.model('Repo', repoSchema);
exports.Commit = mongoose.model('Commit', commitSchema);
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"homepage": "https://github.com/lukasmartinelli/flinter",
"dependencies": {
"express": "^4.10.2",
"mongoose": "^3.8.22",
"request": "^2.49.0"
},
"devDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ var autocomplete = require('./autocomplete');

var options = {
accessToken: process.env.GITHUB_TOKEN,
port: process.env.VCAP_APP_PORT || 3000,
port: process.env.VCAP_APP_PORT || 3000
};

if(!options.accessToken) {
throw 'No Github Access token specified.';
}

app.use(express.static(path.join(__dirname ,'/public')));
app.get('/autocomplete/:search',autocomplete.find);
app.use(express.static(path.join(__dirname, '/public')));
app.get('/autocomplete/:search', autocomplete.find);

http.listen(options.port);
43 changes: 43 additions & 0 deletions tests/models.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
'use strict';
var should = require('should');
var models = require('../models');

describe('repo', function() {
it('can be created', function() {
var repo = new models.Repo({
repo: 'sandstorm-io/sandstorm',
commits: [{ sha: '60d806b05653d2d8c305a06928bebf604d3a6009'},
{ sha: '1ab9d877b6efe62a1eb190024cd67cbc6d91d21a' }]
});
should(repo.repo).equal('sandstorm-io/sandstorm');
should(repo.commits.length).equal(2);
});
});

describe('commit', function() {
it('can be created', function() {
var c1 = new models.Commit({
repo: 'sandstorm-io/sandstorm',
sha: '60d806b05653d2d8c305a06928bebf604d3a6009',
date: new Date(),
flintStatus: 0
});
var c2 = new models.Commit({
repo: 'sandstorm-io/sandstorm',
sha: '1ab9d877b6efe62a1eb190024cd67cbc6d91d21a',
date: new Date(),
flintOutput: [{ file: 'root/src/sodium/api.h',
lineno: 1,
message: 'Missing include guard.'
},
{ file: 'root/src/sandstorm/union-fs.c++',
lineno: 575,
message: 'Single-argument constructor may inadvertedly be used as a type conversion constructor.'
}],
flintStatus: 1
});
should.exist(c1.date);
should(c1.flintOutput.length).equal(0);
should(c2.flintOutput.length).equal(2);
});
});

0 comments on commit 003ff36

Please sign in to comment.