Skip to content

Commit

Permalink
adds lib/index.js and test/e2e.js to expose/test all methods
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonic committed Dec 27, 2014
1 parent eec1f89 commit 77d54b3
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ When I see *junior* developers using
I can't help but think:
what are you *doing* that was ***too complicated for callbacks***?

So when a module *forces* me to use them "***its a no from me***."
So when a module *forces* me to use them
["***its a no from me***"](http://i.imgur.com/TgTX9Kf.jpg)

![promises broken](http://i.imgur.com/3bzRW8y.jpg)
6 changes: 6 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
CREATE: require('./create'),
READ: require('./read'),
UPDATE: require('./update'),
DELETE: require('./delete')
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "esta",
"version": "1.0.4",
"version": "1.0.5",
"description": "The Simplest ElasticSearch Node.js Client'",
"main": "index.js",
"main": "lib/index.js",
"directories": {
"test": "test"
},
Expand Down
31 changes: 31 additions & 0 deletions test/e2e.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
var test = require('tape');
var chalk = require('chalk');
var faker = require('faker');

var ES = require('../lib/index');

test(chalk.cyan('E2E CREATE, READ & DELETE a Record'), function (t) {
var record = {
type: 'tweet',
index: 'twitter',
id: Math.floor(Math.random() * (1000000)),
message: faker.hacker.phrase()
}

var rec = {}; // make a copy of rec for later.
for(var key in record) {
if(record.hasOwnProperty(key)) {
rec[key] = record[key];
}
}
ES.CREATE(record, function(err, res) {
ES.DELETE(rec, function(err3, res3) {
t.equal(res3.found, true, chalk.green("✓ Record Exists - Lets Delete it!"));
// attempt to read record - it should fail
ES.READ(rec, function(err4, res4){
t.equal(res4.found, false, chalk.green("✓ Record Deleted"));
t.end();
})
});
});
});

0 comments on commit 77d54b3

Please sign in to comment.