Skip to content

Commit 868a9d0

Browse files
committed
remove node-tap
1 parent 92e75f0 commit 868a9d0

File tree

4 files changed

+57
-65
lines changed

4 files changed

+57
-65
lines changed

lib/connection-parameters.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,7 @@ var val = function(key, config) {
44
return config[key] ||
55
process.env['PG' + key.toUpperCase()] ||
66
defaults[key];
7-
}
8-
9-
var ConnectionParameters = function(config) {
10-
config = typeof config == 'string' ? parse(config) : (config || {});
11-
this.user = val('user', config);
12-
this.database = val('database', config);
13-
this.port = parseInt(val('port', config));
14-
this.host = val('host', config);
15-
this.password = val('password', config);
16-
this.binary = val('binary', config);
17-
this.ssl = config.ssl || defaults.ssl;
18-
}
7+
};
198

209
var url = require('url');
2110
//parses a connection string
@@ -33,6 +22,17 @@ var parse = function(str) {
3322
config.password = auth[1];
3423
config.port = result.port;
3524
return config;
36-
}
25+
};
26+
27+
var ConnectionParameters = function(config) {
28+
config = typeof config == 'string' ? parse(config) : (config || {});
29+
this.user = val('user', config);
30+
this.database = val('database', config);
31+
this.port = parseInt(val('port', config));
32+
this.host = val('host', config);
33+
this.password = val('password', config);
34+
this.binary = val('binary', config);
35+
this.ssl = config.ssl || defaults.ssl;
36+
};
3737

3838
module.exports = ConnectionParameters;
Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
var test = require('tap').test;
2-
1+
var helper = require(__dirname + '/../test-helper');
2+
var assert = require('assert');
33
var ConnectionParameters = require(__dirname + '/../../../lib/connection-parameters');
44
var defaults = require(__dirname + '/../../../lib').defaults;
55

@@ -8,29 +8,27 @@ for(var key in process.env) {
88
delete process.env[key];
99
}
1010

11-
test('ConnectionParameters construction', function(t) {
12-
t.ok(new ConnectionParameters(), 'with null config');
13-
t.ok(new ConnectionParameters({user: 'asdf'}), 'with config object');
14-
t.ok(new ConnectionParameters('pg://localhost/postgres'), 'with connection string');
15-
t.end();
16-
})
11+
test('ConnectionParameters construction', function() {
12+
assert.ok(new ConnectionParameters(), 'with null config');
13+
assert.ok(new ConnectionParameters({user: 'asdf'}), 'with config object');
14+
assert.ok(new ConnectionParameters('pg://localhost/postgres'), 'with connection string');
15+
});
1716

18-
var compare = function(t, actual, expected, type) {
19-
t.equal(actual.user, expected.user, type + ' user');
20-
t.equal(actual.database, expected.database, type + ' database');
21-
t.equal(actual.port, expected.port, type + ' port');
22-
t.equal(actual.host, expected.host, type + ' host');
23-
t.equal(actual.password, expected.password, type + ' password');
24-
t.equal(actual.binary, expected.binary, type + ' binary');
25-
}
17+
var compare = function(actual, expected, type) {
18+
assert.equal(actual.user, expected.user, type + ' user');
19+
assert.equal(actual.database, expected.database, type + ' database');
20+
assert.equal(actual.port, expected.port, type + ' port');
21+
assert.equal(actual.host, expected.host, type + ' host');
22+
assert.equal(actual.password, expected.password, type + ' password');
23+
assert.equal(actual.binary, expected.binary, type + ' binary');
24+
};
2625

27-
test('ConnectionParameters initializing from defaults', function(t) {
26+
test('ConnectionParameters initializing from defaults', function() {
2827
var subject = new ConnectionParameters();
29-
compare(t, subject, defaults, 'defaults');
30-
t.end();
31-
})
28+
compare(subject, defaults, 'defaults');
29+
});
3230

33-
test('ConnectionParameters initializing from config', function(t) {
31+
test('ConnectionParameters initializing from config', function() {
3432
var config = {
3533
user: 'brian',
3634
database: 'home',
@@ -42,8 +40,7 @@ test('ConnectionParameters initializing from config', function(t) {
4240
ssl: {
4341
asdf: 'blah'
4442
}
45-
}
43+
};
4644
var subject = new ConnectionParameters(config);
47-
compare(t, subject, config, 'config');
48-
t.end();
49-
})
45+
compare(subject, config, 'config');
46+
});

test/unit/connection-parameters/environment-variable-tests.js

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
var test = require('tap').test;
2-
1+
var helper = require(__dirname + '/../test-helper');
2+
var assert = require('assert');
33
var ConnectionParameters = require(__dirname + '/../../../lib/connection-parameters');
44
var defaults = require(__dirname + '/../../../lib').defaults;
55

6-
76
//clear process.env
87
var realEnv = {};
98
for(var key in process.env) {
109
realEnv[key] = process.env[key];
1110
delete process.env[key];
1211
}
1312

14-
1513
test('ConnectionParameters initialized from environment variables', function(t) {
1614
process.env['PGHOST'] = 'local';
1715
process.env['PGUSER'] = 'bmc2';
@@ -20,28 +18,26 @@ test('ConnectionParameters initialized from environment variables', function(t)
2018
process.env['PGPASSWORD'] = 'open';
2119

2220
var subject = new ConnectionParameters();
23-
t.equal(subject.host, 'local', 'env host');
24-
t.equal(subject.user, 'bmc2', 'env user');
25-
t.equal(subject.port, 7890, 'env port');
26-
t.equal(subject.database, 'allyerbase', 'env database');
27-
t.equal(subject.password, 'open', 'env password');
28-
t.end();
29-
})
21+
assert.equal(subject.host, 'local', 'env host');
22+
assert.equal(subject.user, 'bmc2', 'env user');
23+
assert.equal(subject.port, 7890, 'env port');
24+
assert.equal(subject.database, 'allyerbase', 'env database');
25+
assert.equal(subject.password, 'open', 'env password');
26+
});
3027

3128
test('ConnectionParameters initialized from mix', function(t) {
3229
delete process.env['PGPASSWORD'];
3330
delete process.env['PGDATABASE'];
3431
var subject = new ConnectionParameters({
3532
user: 'testing',
3633
database: 'zugzug'
37-
})
38-
t.equal(subject.host, 'local', 'env host');
39-
t.equal(subject.user, 'testing', 'config user');
40-
t.equal(subject.port, 7890, 'env port');
41-
t.equal(subject.database, 'zugzug', 'config database');
42-
t.equal(subject.password, defaults.password, 'defaults password');
43-
t.end();
44-
})
34+
});
35+
assert.equal(subject.host, 'local', 'env host');
36+
assert.equal(subject.user, 'testing', 'config user');
37+
assert.equal(subject.port, 7890, 'env port');
38+
assert.equal(subject.database, 'zugzug', 'config database');
39+
assert.equal(subject.password, defaults.password, 'defaults password');
40+
});
4541

4642
//clear process.env
4743
for(var key in process.env) {
@@ -51,13 +47,12 @@ for(var key in process.env) {
5147
test('connection string parsing', function(t) {
5248
var string = 'postgres://brian:pw@boom:381/lala';
5349
var subject = new ConnectionParameters(string);
54-
t.equal(subject.host, 'boom', 'string host');
55-
t.equal(subject.user, 'brian', 'string user');
56-
t.equal(subject.password, 'pw', 'string password');
57-
t.equal(subject.port, 381, 'string port');
58-
t.equal(subject.database, 'lala', 'string database');
59-
t.end();
60-
})
50+
assert.equal(subject.host, 'boom', 'string host');
51+
assert.equal(subject.user, 'brian', 'string user');
52+
assert.equal(subject.password, 'pw', 'string password');
53+
assert.equal(subject.port, 381, 'string port');
54+
assert.equal(subject.database, 'lala', 'string database');
55+
});
6156

6257
//restore process.env
6358
for(var key in realEnv) {

test/unit/utils-tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var defaults = require(__dirname + "/../../lib").defaults;
55
//this tests the monkey patching
66
//to ensure comptability with older
77
//versions of node
8-
test("EventEmitter.once", function() {
8+
test("EventEmitter.once", function(t) {
99

1010
//an event emitter
1111
var stream = new MemoryStream();

0 commit comments

Comments
 (0)