Skip to content

Commit

Permalink
fix context
Browse files Browse the repository at this point in the history
  • Loading branch information
osher committed Jan 22, 2015
1 parent 7023269 commit e458fb6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
4 changes: 2 additions & 2 deletions lib/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ Context.prototype.config = function(args) {
this.target =
{ host : this.args.host
, port : this.args.port
, user : this.args.user || 'postgres'
, password : this.args.password || null
, user : this.args.user
, password : this.args.password
, database : args.database
};
/**
Expand Down
29 changes: 19 additions & 10 deletions test/lib.context.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,27 @@ module.exports =
);
}
}
, "when used with no empty args" :
{ "should throw a friendly error":
, "when used with empty args" :
{ "should not fail":
function() {
(function() {
ctx.config(
{ }
, { }
)
}).should.throw
sut.clear();
ctx = sut.init()
ctx.config( {}, {} )
}
, "should leave target.user empty - so it would be overrun in test context" :
function() {
Should(ctx.target.user).not.be.ok;
}
, "should leave target.password empty - so it would be overrun in test context" :
function() {
Should(ctx.target.password).not.be.ok;
}
, "should leave target.database empty - so it would be overrun in test context" :
function() {
Should(ctx.target.database).not.be.ok;
}
}
, "when used with minimal args" :
, "when used with partial args" :
{ beforeAll:
function() {
ctx.config(
Expand All @@ -119,7 +128,7 @@ module.exports =
ctx.target.should.eql(
{ host : "localhost"
, port : 5432
, user : "postgres"
, user : undefined
, password: null
, database: "testdb"
}
Expand Down

0 comments on commit e458fb6

Please sign in to comment.