Browse files

Make DB.status better

  • Loading branch information...
1 parent f68ed71 commit 424781f6dbfc316e7590bf5180a5f8deebc5e443 @wezm committed Apr 4, 2011
Showing with 11 additions and 4 deletions.
  1. +6 −2 src/db.coffee
  2. +5 −2 test/db_test.coffee
View
8 src/db.coffee
@@ -10,6 +10,11 @@ class DB
constructor: (@database) ->
throw new Error("default database must be passed to new") unless @database
+ _initRpcArgs: (options) ->
+ args = {}
+ args.DB = options.database or @database
+ args
+
open: (@host = 'localhost', @port = 1978) ->
# This is a bit of a hack... in order to use the 0.4 http API
agent = http.getAgent(@host, @port)
@@ -68,8 +73,7 @@ class DB
else
throw new Error("Invalid number of arguments (#{args.length}) to status");
- rpc_args = {}
- rpc_args.DB = options.database or @database
+ rpc_args = this._initRpcArgs options
@rpcClient.call 'status', rpc_args, (error, status, output) ->
if error?
callback error, output
View
7 test/db_test.coffee
@@ -53,11 +53,14 @@ module.exports =
test.expect 2
db.status (error, output) ->
test.ok Object.keys(output).length > 0
- test.ok output.hasOwnProperty 'count'
+ test.equal output.path, 'test.kct'
test.done()
+ 'allows the database to be specified': (test) ->
+ test.expect 2
+ db.status {database: 'test2.kct'}, (error, output) ->
test.ok Object.keys(output).length > 0
- test.ok output.hasOwnProperty 'count'
+ test.equal output.path, 'test2.kct'
test.done()
# TODO: set should accept numeric values and store them as such in Kyoto.

0 comments on commit 424781f

Please sign in to comment.