Skip to content

Commit

Permalink
Merge pull request #77 from shekenahglory/staging
Browse files Browse the repository at this point in the history
9.3 for travis
  • Loading branch information
shekenahglory committed Oct 15, 2014
2 parents 2bf4297 + 0349067 commit 30b70f2
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@
- sed -e 's/exports.testmode = false/exports.testmode = true/g' config.js > foo
- mv foo config.js
- cat config.js
- sudo service postgresql stop
- sudo service postgresql start 9.3
- psql --version
- "echo create database blobvault as user postgres"
- psql -c 'create database blobvault;' -U postgres
- psql -d blobvault -c "\conninfo" -U postgres
- node migration.js
- ./node_modules/knex/lib/bin/cli.js migrate:latest
- "echo make test script executable"
- chmod +x test.sh
- "echo End of before script"
addons:
postgresql: 9.3
7 changes: 6 additions & 1 deletion api/attestation/phone.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ exports.get = function(req,res,next) {
var phoneNumber = normalizePhone(req.body.phone.country_code, req.body.phone.number);

exports.store.getPhoneAttestation(identity_id, phoneNumber, function(resp){
console.log("GetPhoneAttestation Response:", resp)
if (resp.error) {
response.json({result:'error', message:'attestation DB error'}).status(500).pipe(res);

Expand Down Expand Up @@ -78,10 +79,13 @@ exports.update = function (req, res, next) {
var identity_id = req.params.identity_id;
var phoneNumber = normalizePhone(req.body.phone.country_code, req.body.phone.number);
var q = new Queue;

console.log("attestation:phone:update:identity_id", identity_id,"phoneNumber:", phoneNumber)

q.series([
function(lib) {
exports.store.getPhoneAttestation(identity_id, phoneNumber, function(resp){
console.log("update:getPhoneAttestation:", resp)
if (resp.error) {
response.json({result:'error', message:'attestation DB error'}).status(500).pipe(res);
lib.terminate();
Expand Down Expand Up @@ -181,6 +185,7 @@ exports.update = function (req, res, next) {
};

exports.store.insert_or_update_where(options, function(db_resp) {
console.log("inert_or_update_where:resp:", db_resp)
if (db_resp.error) {
response.json({result:'error', message:'attestation database error'}).status(500).pipe(res);
lib.terminate();
Expand Down Expand Up @@ -248,4 +253,4 @@ var normalizePhone = function (country, number) {

return normalized;
}


1 change: 1 addition & 0 deletions lib/dbcommon.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ var dbcommon = function(db) {
.select()
.nodeify(function(err, resp) {
if (err) {
console.log("The real error is:", err)
cb({error:new Error('Attestation DB error')});
} else {
cb(resp);
Expand Down
1 change: 1 addition & 0 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ node_modules/.bin/mocha --ui tdd -R spec test/test-guard-requests.js &&
node_modules/.bin/mocha --ui tdd -R spec test/test-profile-details.js &&
node_modules/.bin/mocha --ui tdd -R spec test/test-2fa.js &&
node_modules/.bin/mocha --ui tdd -R spec test/test-attestation.js &&
node test/test-json.js &&
node test/test-libutils.js
3 changes: 1 addition & 2 deletions test/test-attestation.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,6 @@ describe('Attestation:', function() {
});
});


var validAttestation = function (attestation) {

var utils = require('../lib/utils');
Expand All @@ -395,4 +394,4 @@ var validAttestation = function (attestation) {
}

return true;
};
};
40 changes: 40 additions & 0 deletions test/test-json.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
var config = require('../config');
var store = require('../lib/store')(config.dbtype);
var assert = require('assert')

var QL = require('queuelib')

var q = new QL;

q.series([
function(lib) {
store.db.raw('select version()').then(function(resp) {
console.log("VERSION:", resp)
lib.done();
});
},
function(lib) {
store.db('attestations')
.truncate()
.then(function() {
return store.db('attestations')
.insert({id:'catcat',payload:{foo:'bar',life:42,animal:{cat:'gabby'}}})
})
.then(function() {
lib.done()
});
},
function(lib) {
store.db('attestations')
.whereRaw("payload->>'life' = ?", 42)
.select()
.then(function(resp) {
assert.equal(84,resp[0].payload.life*2)
assert.equal('gabby',resp[0].payload.animal.cat)
console.log("all done")
lib.done()
process.exit()
})
}
])

0 comments on commit 30b70f2

Please sign in to comment.