-
Notifications
You must be signed in to change notification settings - Fork 29
/
connection_settings_tests.dart
67 lines (58 loc) · 2.09 KB
/
connection_settings_tests.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
library connection_settings_tests;
import 'package:test/test.dart';
import '../lib/redis_client.dart';
main() {
group('RedisConnectionSettings', () {
/// - `'pass@host:port/db'`
/// - `'pass@host:port'`
/// - `'pass@host'`
/// - `'host'`
/// - `null` defaults to `'localhost:6379/0'`
group('connectionStrings should be properly parsed:', () {
test("pass@host:port/db", () {
var cs = new RedisConnectionSettings("[email protected]:1234/2");
expect(cs.password, equals("pass"));
expect(cs.hostname, equals("some.host"));
expect(cs.port, equals(1234));
expect(cs.db, equals(2));
});
test("pass@host:port", () {
var cs = new RedisConnectionSettings("[email protected]:1234");
expect(cs.password, equals("pass"));
expect(cs.hostname, equals("some.host"));
expect(cs.port, equals(1234));
expect(cs.db, equals(0));
});
test("pass@host", () {
var cs = new RedisConnectionSettings("[email protected]");
expect(cs.password, equals("pass"));
expect(cs.hostname, equals("some.host"));
expect(cs.port, equals(6379));
expect(cs.db, equals(0));
});
});
test("host:1234", () {
var cs = new RedisConnectionSettings("some.host:1234");
expect(cs.password, equals(null));
expect(cs.hostname, equals("some.host"));
expect(cs.port, equals(1234));
expect(cs.db, equals(0));
});
test("host", () {
var cs = new RedisConnectionSettings("some.host");
expect(cs.password, equals(null));
expect(cs.hostname, equals("some.host"));
expect(cs.port, equals(6379));
expect(cs.db, equals(0));
});
test("empty string, null and no parameter should result in the default settings", () {
var settings = [ new RedisConnectionSettings(""), new RedisConnectionSettings(null), new RedisConnectionSettings() ];
settings.forEach((cs) {
expect(cs.password, equals(null));
expect(cs.hostname, equals("localhost"));
expect(cs.port, equals(6379));
expect(cs.db, equals(0));
});
});
});
}