-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove Bonsai ElasticSearch Provider from tests. minor re-factor see: #…
- Loading branch information
Showing
4 changed files
with
59 additions
and
51 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
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 |
---|---|---|
|
@@ -24,8 +24,8 @@ module.exports = function options(record, method) { | |
} | ||
}; | ||
// example url: https://myuser:[email protected] | ||
if(process.env.SEARCHBOX_SSL_URL || process.env.BONSAI_URL) { | ||
var u = url.parse(process.env.SEARCHBOX_SSL_URL || process.env.BONSAI_URL); | ||
if(process.env.SEARCHBOX_SSL_URL) { // || process.env.BONSAI_URL) { | ||
var u = url.parse(process.env.SEARCHBOX_SSL_URL); // || process.env.BONSAI_URL); | ||
var unpw = u.auth.split(':'); // auth is everything between // and @ | ||
var username = unpw[0]; | ||
var password = unpw[1]; | ||
|
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 |
---|---|---|
@@ -1,18 +1,25 @@ | ||
var test = require('tape'); | ||
var chalk = require('chalk'); | ||
var uncache = require('./uncache').uncache; | ||
console.log(' - - - - - - - - - - - - - - - - - - - - - - - - process.env.SEARCHBOX_SSL_URL:'); | ||
console.log(process.env.SEARCHBOX +' || ' + process.env.SEARCHBOX_SSL_URL); | ||
process.env.SEARCHBOX = process.env.SEARCHBOX || process.env.SEARCHBOX_SSL_URL; | ||
console.log(process.env.SEARCHBOX +' || ' + process.env.SEARCHBOX_SSL_URL); | ||
|
||
test(chalk.cyan('Force HTTP Error with bad UN:PW'), function (t) { | ||
// please don't spam this SearchBox ElasticSearch account with Records! | ||
// Its JUST for Testing this module! thanks! :-) | ||
// process.env.SEARCHBOX = process.env.SEARCHBOX_SSL_URL; | ||
process.env.SEARCHBOX_SSL_URL = 'https://un:[email protected]' | ||
var ES_URL = process.env.SEARCHBOX_SSL_URL || '127.0.0.1:9200'; | ||
console.log(' - - - - - - - - - - - - - - - - - - - - - res:'); | ||
console.log(process.env.SEARCHBOX_SSL_URL); | ||
console.log(' - - - - - - - - - - - - - - - - - - - - - - - - '); | ||
// var ES_URL = process.env.SEARCHBOX_SSL_URL || '127.0.0.1:9200'; | ||
// https://nodejs.org/docs/latest/api/globals.html#globals_require_cache | ||
uncache('../lib/index'); // reload http_request sans SSL! (localhost) | ||
var ES = require('../lib/index'); | ||
ES.CONNECT(function (res) { | ||
console.log(res); | ||
t.equal(res.status, 'error', chalk.green("✓ Error forced. (we wanted this!)")); | ||
|
||
t.end(); | ||
}); | ||
}); | ||
|
@@ -36,44 +43,43 @@ test(chalk.cyan('Exercise http_request req.on("error") handler'), function (t) { | |
}); | ||
|
||
|
||
test(chalk.cyan('CONNECT to Bonsai on HEROKU!'), function (t) { | ||
// please don't spam this Bonsai ElasticSearch account with Records! | ||
// Its JUST for Testing this module! thanks! :-) | ||
delete process.env.SEARCHBOX_SSL_URL; // unset SearchBox so we can test Bonsai | ||
process.env.BONSAI_URL = 'https://8py6wr37:[email protected]' | ||
// https://nodejs.org/docs/latest/api/globals.html#globals_require_cache | ||
uncache('../lib/index'); // reload http_request sans SSL! (localhost) | ||
var ES = require('../lib/index'); | ||
// don't specify the index | ||
ES.CONNECT(function (res) { | ||
console.log(res); | ||
t.equal(res.status, 200, chalk.green("✓ Status 200 - HEROKU Bonsai works like a charm")); | ||
t.end(); | ||
}); | ||
}); | ||
|
||
test(chalk.cyan('CREATE a record on HEROKU/Bonsai'), function (t) { | ||
process.env.BONSAI_URL = 'https://8py6wr37:[email protected]' | ||
var ES = require('../lib/index'); | ||
var record = require('./fake_record.js')(); // fake record | ||
ES.CREATE(record, function (res) { | ||
console.log(res) | ||
t.equal(res.created, true, chalk.green("✓ Record Created on Heroku/Bonsai")); | ||
t.end(); | ||
}); | ||
}); | ||
// test(chalk.cyan('CONNECT to Bonsai on HEROKU!'), function (t) { | ||
// // please don't spam this Bonsai ElasticSearch account with Records! | ||
// // Its JUST for Testing this module! thanks! :-) | ||
// delete process.env.SEARCHBOX_SSL_URL; // unset SearchBox so we can test Bonsai | ||
// process.env.BONSAI_URL = 'https://8py6wr37:[email protected]' | ||
// // https://nodejs.org/docs/latest/api/globals.html#globals_require_cache | ||
// uncache('../lib/index'); // reload http_request sans SSL! (localhost) | ||
// var ES = require('../lib/index'); | ||
// // don't specify the index | ||
// ES.CONNECT(function (res) { | ||
// console.log(res); | ||
// t.equal(res.status, 200, chalk.green("✓ Status 200 - HEROKU Bonsai works like a charm")); | ||
// t.end(); | ||
// }); | ||
// }); | ||
// | ||
// test(chalk.cyan('CREATE a record on HEROKU/Bonsai'), function (t) { | ||
// process.env.BONSAI_URL = 'https://8py6wr37:[email protected]' | ||
// var ES = require('../lib/index'); | ||
// var record = require('./fake_record.js')(); // fake record | ||
// ES.CREATE(record, function (res) { | ||
// console.log(res) | ||
// t.equal(res.created, true, chalk.green("✓ Record Created on Heroku/Bonsai")); | ||
// t.end(); | ||
// }); | ||
// }); | ||
|
||
// var searchbox_index = 'bonsai'+new Date().getTime(); | ||
test(chalk.cyan('CONNECT to SearchBox on HEROKU!'), function (t) { | ||
// please don't spam this SearchBox ElasticSearch account with Records! | ||
// Its JUST for Testing this module! thanks! :-) | ||
delete process.env.BONSAI_URL; // so we can test SearchBox now | ||
process.env.SEARCHBOX_SSL_URL = 'https://paas:[email protected]' | ||
// https://nodejs.org/docs/latest/api/globals.html#globals_require_cache | ||
uncache('../lib/index'); // reload http_request sans SSL! (localhost) | ||
process.env.SEARCHBOX_SSL_URL = process.env.SEARCHBOX || process.env.SEARCHBOX_SSL_URL; // see _connection.js | ||
console.log(process.env.SEARCHBOX_SSL_URL); | ||
uncache('../lib/index'); // see: https://github.com/dwyl/decache | ||
var ES = require('../lib/index'); | ||
ES.CONNECT('twitter', function (res) { | ||
console.log(' - - - - - - - - - - - - - - - - - - - - - res:'); | ||
console.log(res); | ||
console.log(' - - - - - - - - - - - - - - - - - - - - - - - - '); | ||
t.equal(res.status, 200, chalk.green("✓ Status 200 - OK")); | ||
t.end(); | ||
}); | ||
|
@@ -93,7 +99,6 @@ test(chalk.cyan('CREATE a record on HEROKU/SearchBox'), function (t) { | |
test(chalk.cyan('Ensure that we clear node require cache to resume testing on localhost'), function(t){ | ||
uncache('../lib/index'); | ||
delete process.env.SEARCHBOX_SSL_URL; // unset SearchBox URL so we can resume testing locally | ||
delete process.env.BONSAI_URL; // same for BONSAI | ||
t.equal(process.env.BONSAI_URL, undefined, chalk.green("✓ Continue testing Local ES.")); | ||
t.equal(process.env.SEARCHBOX_SSL_URL, undefined, chalk.green("✓ Continue testing Local ES.")); | ||
t.end(); | ||
}); |