Skip to content
Browse files

add a unit test. ass a usage example at README.mdw

  • Loading branch information...
1 parent f93d461 commit 6592de32f05cfe056000ac76289ddf62d8d332ce Jihyun Yu committed Apr 3, 2011
Showing with 38 additions and 2 deletions.
  1. +4 −0 README.md
  2. +34 −2 test/simpledb.test.js
View
4 README.md
@@ -341,6 +341,10 @@ deleted.
sdb.deleteItem('<domain>','<itemname>',[ '<attr>', ... ]function( error, result, meta ){
console.log("I felt like destroying something beautiful. "+JSON.stringify(res))
})
+
+ sdb.deleteItem('<domain>','<itemname>',{ '<attr>': [<value1>, ... ], ... }function( error, result, meta ){
+ console.log("I don't know what to write about. "+JSON.stringify(res))
+ })
### select: `sdb.select( query, override, callback )`
View
36 test/simpledb.test.js
@@ -314,6 +314,31 @@ module.exports = {
assert.equal('b2',res[1].$ItemName)
assert.equal('two', res[1].field )
+ ;sdb.deleteItem('simpledbtest','item1', {'woz': ['one']},function(err,res,meta) {
+ debugres(err,res,meta)
+
+ ;sdb.getItem('simpledbtest','item1',function(err,res,meta){
+ debugres(err,res,meta)
+ assert.isNull(err)
+ assert.equal('item1',res.$ItemName)
+ assert.equal(1,parseInt(res.foo,10))
+ assert.equal('BAR',res.bar)
+ assert.equal('two',res.woz)
+ assert.equal("'n",res.quote)
+
+ ;sdb.deleteItem('simpledbtest','item1', ['foo', 'bar'],function(err,res,meta) {
+ debugres(err,res,meta)
+ assert.isNull(err)
+
+ ;sdb.getItem('simpledbtest','item1',function(err,res,meta){
+ debugres(err,res,meta)
+ assert.isNull(err)
+ assert.equal('item1',res.$ItemName)
+ assert.isNull(res.foo)
+ assert.isNull(res.bar)
+ assert.equal('two',res.woz)
+ assert.equal("'n",res.quote)
+
;sdb.deleteItem('simpledbtest','item1',function(err,res,meta){
debugres(err,res,meta)
assert.isNull(err)
@@ -331,7 +356,7 @@ module.exports = {
debugres(err,res,meta)
assert.isNotNull(err)
- }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) })
+ }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) })
},
example: function() {
@@ -363,9 +388,16 @@ function debugres(err,res,meta) {
*/
}
+assert.isNull = function(obj) {
+ return null == obj;
+}
+
+assert.isNotNull = function(obj) {
+ return null != obj;
+}
if( 'run' == process.argv[2] ) {
for( fname in module.exports ) {
module.exports[fname]()
}
-}
+}

0 comments on commit 6592de3

Please sign in to comment.
Something went wrong with that request. Please try again.