Skip to content

Commit b536867

Browse files
author
za-creature
committed
Merge pull request #1 from za-creature/master
unittest
2 parents 5493a52 + 20a2cbc commit b536867

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

test/unit/connection-parameters/creation-tests.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,21 @@ test('libpq connection string building', function() {
138138
assert.equal(subject.password, sourceConfig.password);
139139
});
140140

141-
test('password contains weird characters', function() {
142-
var strang = 'pg://my first name:is&%awesome!@localhost:9000';
141+
test('username or password contains weird characters', function() {
142+
var strang = 'pg://my f%irst name:is&%awesome!@localhost:9000';
143143
var subject = new ConnectionParameters(strang);
144-
assert.equal(subject.user, 'my first name');
144+
assert.equal(subject.user, 'my f%irst name');
145145
assert.equal(subject.password, 'is&%awesome!');
146146
assert.equal(subject.host, 'localhost');
147147
});
148+
149+
test("url is properly encoded", function() {
150+
var encoded = "pg://bi%25na%25%25ry%20:s%40f%23@localhost/%20u%2520rl";
151+
var subject = new ConnectionParameters(encoded);
152+
assert.equal(subject.user, "bi%na%%ry ");
153+
assert.equal(subject.password, "s@f#");
154+
assert.equal(subject.host, 'localhost');
155+
assert.equal(subject.path, " u%20rl");
156+
});
148157

149158
});

0 commit comments

Comments
 (0)