Skip to content

Commit 954f1f3

Browse files
committed
Merge pull request #808 from fintura/refactor-tests
Refactor the test suite and remove duplicated code
2 parents 92839c6 + a5938f3 commit 954f1f3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+68
-459
lines changed

test/auth.spec.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ describe("client authentication", function () {
1111
});
1212
});
1313

14-
function allTests(parser, ip) {
14+
helper.allTests(function(parser, ip, args) {
15+
1516
describe("using " + parser + " and " + ip, function () {
1617
var args = config.configureClient(parser, ip);
1718
var auth = 'porkchopsandwiches';
@@ -73,13 +74,6 @@ describe("client authentication", function () {
7374
});
7475
});
7576
});
76-
}
77-
78-
['javascript', 'hiredis'].forEach(function (parser) {
79-
allTests(parser, "/tmp/redis.sock");
80-
['IPv4', 'IPv6'].forEach(function (ip) {
81-
allTests(parser, ip);
82-
})
8377
});
8478

8579
after(function (done) {

test/commands/blpop.spec.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ var redis = config.redis;
55

66
describe("The 'blpop' method", function () {
77

8-
function allTests(parser, ip) {
9-
var args = config.configureClient(parser, ip);
8+
helper.allTests(function(parser, ip, args) {
109

1110
describe("using " + parser + " and " + ip, function () {
1211
var client;
@@ -53,12 +52,5 @@ describe("The 'blpop' method", function () {
5352
bclient.end();
5453
});
5554
});
56-
}
57-
58-
['javascript', 'hiredis'].forEach(function (parser) {
59-
allTests(parser, "/tmp/redis.sock");
60-
['IPv4', 'IPv6'].forEach(function (ip) {
61-
allTests(parser, ip);
62-
})
6355
});
6456
});

test/commands/client.spec.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ var redis = config.redis;
55

66
describe("The 'client' method", function () {
77

8-
function allTests(parser, ip) {
9-
var args = config.configureClient(parser, ip);
8+
helper.allTests(function(parser, ip, args) {
109
var pattern = /addr=/;
1110

1211
describe("using " + parser + " and " + ip, function () {
@@ -50,12 +49,5 @@ describe("The 'client' method", function () {
5049
});
5150
});
5251
});
53-
}
54-
55-
['javascript', 'hiredis'].forEach(function (parser) {
56-
allTests(parser, "/tmp/redis.sock");
57-
['IPv4', 'IPv6'].forEach(function (ip) {
58-
allTests(parser, ip);
59-
})
6052
});
6153
});

test/commands/dbsize.spec.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ var uuid = require('uuid');
77

88
describe("The 'dbsize' method", function () {
99

10-
function allTests(parser, ip) {
11-
var args = config.configureClient(parser, ip);
10+
helper.allTests(function(parser, ip, args) {
1211

1312
describe("using " + parser + " and " + ip, function () {
1413
var key, value;
@@ -95,12 +94,5 @@ describe("The 'dbsize' method", function () {
9594
});
9695
});
9796
});
98-
}
99-
100-
['javascript', 'hiredis'].forEach(function (parser) {
101-
allTests(parser, "/tmp/redis.sock");
102-
['IPv4', 'IPv6'].forEach(function (ip) {
103-
allTests(parser, ip);
104-
})
10597
});
10698
});

test/commands/del.spec.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ var redis = config.redis;
55

66
describe("The 'del' method", function () {
77

8-
function allTests(parser, ip) {
9-
var args = config.configureClient(parser, ip);
8+
helper.allTests(function(parser, ip, args) {
109

1110
describe("using " + parser + " and " + ip, function () {
1211
var client;
@@ -40,12 +39,5 @@ describe("The 'del' method", function () {
4039
client.end();
4140
});
4241
});
43-
}
44-
45-
['javascript', 'hiredis'].forEach(function (parser) {
46-
allTests(parser, "/tmp/redis.sock");
47-
['IPv4', 'IPv6'].forEach(function (ip) {
48-
allTests(parser, ip);
49-
})
5042
});
5143
});

test/commands/eval.spec.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ var helper = require("../helper");
55
var redis = config.redis;
66

77
describe("The 'eval' method", function () {
8-
function allTests(parser, ip) {
9-
var args = config.configureClient(parser, ip);
8+
9+
helper.allTests(function(parser, ip, args) {
1010

1111
describe("using " + parser + " and " + ip, function () {
1212
var client;
@@ -188,12 +188,5 @@ describe("The 'eval' method", function () {
188188
});
189189
});
190190
});
191-
}
192-
193-
['javascript', 'hiredis'].forEach(function (parser) {
194-
allTests(parser, "/tmp/redis.sock");
195-
['IPv4', 'IPv6'].forEach(function (ip) {
196-
allTests(parser, ip);
197-
})
198191
});
199192
});

test/commands/exits.spec.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ var redis = config.redis;
55

66
describe("The 'exits' method", function () {
77

8-
function allTests(parser, ip) {
9-
var args = config.configureClient(parser, ip);
8+
helper.allTests(function(parser, ip, args) {
109

1110
describe("using " + parser + " and " + ip, function () {
1211
var client;
@@ -32,12 +31,5 @@ describe("The 'exits' method", function () {
3231
client.end();
3332
});
3433
});
35-
}
36-
37-
['javascript', 'hiredis'].forEach(function (parser) {
38-
allTests(parser, "/tmp/redis.sock");
39-
['IPv4', 'IPv6'].forEach(function (ip) {
40-
allTests(parser, ip);
41-
})
4234
});
4335
});

test/commands/expire.spec.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ var redis = config.redis;
55

66
describe("The 'expire' method", function () {
77

8-
function allTests(parser, ip) {
9-
var args = config.configureClient(parser, ip);
8+
helper.allTests(function(parser, ip, args) {
109

1110
describe("using " + parser + " and " + ip, function () {
1211
var client;
@@ -31,12 +30,5 @@ describe("The 'expire' method", function () {
3130
client.end();
3231
});
3332
});
34-
}
35-
36-
['javascript', 'hiredis'].forEach(function (parser) {
37-
allTests(parser, "/tmp/redis.sock");
38-
['IPv4', 'IPv6'].forEach(function (ip) {
39-
allTests(parser, ip);
40-
})
4133
});
4234
});

test/commands/flushdb.spec.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ var uuid = require('uuid');
77

88
describe("The 'flushdb' method", function () {
99

10-
function allTests(parser, ip) {
11-
var args = config.configureClient(parser, ip);
10+
helper.allTests(function(parser, ip, args) {
1211

1312
describe("using " + parser + " and " + ip, function () {
1413
var key, key2;
@@ -104,12 +103,5 @@ describe("The 'flushdb' method", function () {
104103
});
105104
});
106105
});
107-
}
108-
109-
['javascript', 'hiredis'].forEach(function (parser) {
110-
allTests(parser, "/tmp/redis.sock");
111-
['IPv4', 'IPv6'].forEach(function (ip) {
112-
allTests(parser, ip);
113-
})
114106
});
115107
});

test/commands/get.spec.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ var uuid = require('uuid');
77

88
describe("The 'get' method", function () {
99

10-
function allTests(parser, ip) {
11-
var args = config.configureClient(parser, ip);
10+
helper.allTests(function(parser, ip, args) {
1211

1312
describe("using " + parser + " and " + ip, function () {
1413
var key, value;
@@ -81,12 +80,5 @@ describe("The 'get' method", function () {
8180
});
8281
});
8382
});
84-
}
85-
86-
['javascript', 'hiredis'].forEach(function (parser) {
87-
allTests(parser, "/tmp/redis.sock");
88-
['IPv4', 'IPv6'].forEach(function (ip) {
89-
allTests(parser, ip);
90-
})
9183
});
9284
});

0 commit comments

Comments
 (0)