1
1
var assert = require ( 'assert' ) ;
2
2
var ns = require ( '..' ) ;
3
3
4
- describe ( 'ns' , function ( ) {
5
- describe ( 'normal' , function ( ) {
6
- it ( 'should acccept `a`' , function ( ) {
4
+ describe ( 'ns' , function ( ) {
5
+ describe ( 'normal' , function ( ) {
6
+ it ( 'should acccept `a`' , function ( ) {
7
7
assert ( ns ( 'a' ) . normal ) ;
8
8
} ) ;
9
- it ( 'should acccept `a.b`' , function ( ) {
9
+ it ( 'should acccept `a.b`' , function ( ) {
10
10
assert ( ns ( 'a.b' ) . normal ) ;
11
11
} ) ;
12
- it ( 'should acccept `a.b.c`' , function ( ) {
12
+ it ( 'should acccept `a.b.c`' , function ( ) {
13
13
assert ( ns ( 'a.b.c' ) . normal ) ;
14
14
} ) ;
15
- it ( 'should acccept `local.oplog.$main`' , function ( ) {
15
+ it ( 'should acccept `local.oplog.$main`' , function ( ) {
16
16
assert ( ns ( 'local.oplog.$main' ) . normal ) ;
17
17
} ) ;
18
- it ( 'should acccept `local.oplog.rs`' , function ( ) {
18
+ it ( 'should acccept `local.oplog.rs`' , function ( ) {
19
19
assert ( ns ( 'local.oplog.rs' ) . normal ) ;
20
20
} ) ;
21
- it ( 'should not acccept `a.b.$c`' , function ( ) {
21
+ it ( 'should not acccept `a.b.$c`' , function ( ) {
22
22
assert . equal ( ns ( 'a.b.$c' ) . normal , false ) ;
23
23
} ) ;
24
- it ( 'should not acccept `a.b.$.c`' , function ( ) {
24
+ it ( 'should not acccept `a.b.$.c`' , function ( ) {
25
25
assert . equal ( ns ( 'a.b.$.c' ) . normal , false ) ;
26
26
} ) ;
27
27
} ) ;
28
28
29
- it ( 'should identify oplog namespaces' , function ( ) {
29
+ it ( 'should identify oplog namespaces' , function ( ) {
30
30
assert . equal ( ns ( 'a' ) . oplog , false ) ;
31
31
assert . equal ( ns ( 'a.b' ) . oplog , false ) ;
32
32
assert ( ns ( 'local.oplog.rs' ) . oplog ) ;
@@ -35,164 +35,167 @@ describe('ns', function() {
35
35
assert . equal ( ns ( 'local.oplog.$foo' ) . oplog , false ) ;
36
36
} ) ;
37
37
38
- describe ( 'should identify special namespaces' , function ( ) {
39
- it ( 'should NOT accept `a.$.b as special`' , function ( ) {
38
+ describe ( 'should identify special namespaces' , function ( ) {
39
+ it ( 'should NOT accept `a.$.b as special`' , function ( ) {
40
40
assert . equal ( ns ( 'a.$.b' ) . special , false ) ;
41
41
} ) ;
42
- it ( 'should acccept `a.system.foo`' , function ( ) {
42
+ it ( 'should acccept `a.system.foo`' , function ( ) {
43
43
assert ( ns ( 'a.system.foo' ) . special ) ;
44
44
} ) ;
45
- it ( 'should acccept `a.enxcol_.foo`' , function ( ) {
45
+ it ( 'should acccept `a.enxcol_.foo`' , function ( ) {
46
46
assert ( ns ( 'a.enxcol_.foo' ) . special ) ;
47
47
} ) ;
48
- it ( 'should not accept `a.foo`' , function ( ) {
48
+ it ( 'should not accept `a.foo`' , function ( ) {
49
49
assert . equal ( ns ( 'a.foo' ) . special , false ) ;
50
50
} ) ;
51
- it ( 'should not accept `a.systemfoo`' , function ( ) {
51
+ it ( 'should not accept `a.systemfoo`' , function ( ) {
52
52
assert . equal ( ns ( 'a.systemfoo' ) . special , false ) ;
53
53
} ) ;
54
- it ( 'should not accept `a.foo.system.bar`' , function ( ) {
54
+ it ( 'should not accept `a.foo.system.bar`' , function ( ) {
55
55
assert . equal ( ns ( 'a.foo.system.bar' ) . special , false ) ;
56
56
} ) ;
57
- it ( 'should not accept `prefix__mdb_internal_suffix`' , function ( ) {
57
+ it ( 'should not accept `prefix__mdb_internal_suffix`' , function ( ) {
58
58
assert . equal ( ns ( 'prefix__mdb_internal_suffix' ) . special , false ) ;
59
59
} ) ;
60
- it ( 'should not accept `anyDB.prefix__mdb_internal_suffix`' , function ( ) {
61
- assert . equal ( ns ( 'anyDB.prefix__mdb_internal_itsACollectionNow' ) . special , false ) ;
60
+ it ( 'should not accept `anyDB.prefix__mdb_internal_suffix`' , function ( ) {
61
+ assert . equal (
62
+ ns ( 'anyDB.prefix__mdb_internal_itsACollectionNow' ) . special ,
63
+ false ,
64
+ ) ;
62
65
} ) ;
63
- it ( 'should not accept `prefix__mdb_internal_suffix`' , function ( ) {
66
+ it ( 'should not accept `prefix__mdb_internal_suffix`' , function ( ) {
64
67
assert . equal ( ns ( 'prefix__mdb_internal_' ) . special , false ) ;
65
68
} ) ;
66
- it ( 'should acccept `__mdb_internal_suffix`' , function ( ) {
69
+ it ( 'should acccept `__mdb_internal_suffix`' , function ( ) {
67
70
assert ( ns ( '__mdb_internal_suffix' ) . special ) ;
68
71
} ) ;
69
72
} ) ;
70
73
71
- describe ( 'should identify system namespaces' , function ( ) {
72
- it ( 'should acccept `anyDB.enxcol_.` as system`' , function ( ) {
74
+ describe ( 'should identify system namespaces' , function ( ) {
75
+ it ( 'should acccept `anyDB.enxcol_.` as system`' , function ( ) {
73
76
assert ( ns ( 'anyDB.enxcol_.' ) . system ) ;
74
77
} ) ;
75
- it ( 'should acccept `anyDB.system.` as system`' , function ( ) {
78
+ it ( 'should acccept `anyDB.system.` as system`' , function ( ) {
76
79
assert ( ns ( 'anyDB.system.' ) . system ) ;
77
80
} ) ;
78
- it ( 'should acccept `anyDB.system.anyCollSuffix` as system`' , function ( ) {
81
+ it ( 'should acccept `anyDB.system.anyCollSuffix` as system`' , function ( ) {
79
82
assert ( ns ( 'anyDB.system.anyCollSuffix' ) . system ) ;
80
83
} ) ;
81
- it ( 'should NOT acccept `anyDB.anyCollPrefix.system` as system`' , function ( ) {
82
- assert . equal ( ( ns ( 'anyDB.anyCollPrefix.system' ) . system ) , false ) ;
84
+ it ( 'should NOT acccept `anyDB.anyCollPrefix.system` as system`' , function ( ) {
85
+ assert . equal ( ns ( 'anyDB.anyCollPrefix.system' ) . system , false ) ;
83
86
} ) ;
84
- it ( 'should NOT acccept `anyDB.system` as system`' , function ( ) {
85
- assert . equal ( ( ns ( 'anyDB.system' ) . system ) , false ) ;
87
+ it ( 'should NOT acccept `anyDB.system` as system`' , function ( ) {
88
+ assert . equal ( ns ( 'anyDB.system' ) . system , false ) ;
86
89
} ) ;
87
90
// exception for system.profile COMPASS-9377
88
- it ( 'should NOT acccept `anyDB.system.profile as system`' , function ( ) {
89
- assert . equal ( ( ns ( 'anyDB.system.profile' ) . system ) , false ) ;
91
+ it ( 'should NOT acccept `anyDB.system.profile as system`' , function ( ) {
92
+ assert . equal ( ns ( 'anyDB.system.profile' ) . system , false ) ;
90
93
} ) ;
91
- it ( 'should acccept `anyDB.system.profile_anything as system`' , function ( ) {
94
+ it ( 'should acccept `anyDB.system.profile_anything as system`' , function ( ) {
92
95
assert ( ns ( 'anyDB.system.profile_anything' ) . system ) ;
93
96
} ) ;
94
97
} ) ;
95
98
96
- describe ( 'database name validation' , function ( ) {
97
- it ( 'should accept `foo` as a valid database name' , function ( ) {
99
+ describe ( 'database name validation' , function ( ) {
100
+ it ( 'should accept `foo` as a valid database name' , function ( ) {
98
101
assert . equal ( ns ( 'foo' ) . validDatabaseName , true ) ;
99
102
} ) ;
100
- it ( 'should not accept `foo/bar` as a valid database name' , function ( ) {
103
+ it ( 'should not accept `foo/bar` as a valid database name' , function ( ) {
101
104
assert . equal ( ns ( 'foo/bar' ) . validDatabaseName , false ) ;
102
105
} ) ;
103
- it ( 'should not accept `foo bar` as a valid database name' , function ( ) {
106
+ it ( 'should not accept `foo bar` as a valid database name' , function ( ) {
104
107
assert . equal ( ns ( 'foo bar' ) . validDatabaseName , false ) ;
105
108
} ) ;
106
- it ( 'should not accept `foo\\bar` as a valid database name' , function ( ) {
109
+ it ( 'should not accept `foo\\bar` as a valid database name' , function ( ) {
107
110
assert . equal ( ns ( 'foo\\bar' ) . validDatabaseName , false ) ;
108
111
} ) ;
109
- it ( 'should not accept `foo\ "bar` as a valid database name' , function ( ) {
110
- assert . equal ( ns ( 'foo\ "bar' ) . validDatabaseName , false ) ;
112
+ it ( 'should not accept `foo"bar` as a valid database name' , function ( ) {
113
+ assert . equal ( ns ( 'foo"bar' ) . validDatabaseName , false ) ;
111
114
} ) ;
112
- it . skip ( 'should not accept `foo*bar` as a valid database name' , function ( ) {
115
+ it . skip ( 'should not accept `foo*bar` as a valid database name' , function ( ) {
113
116
assert . equal ( ns ( 'foo*bar' ) . validDatabaseName , false ) ;
114
117
} ) ;
115
- it . skip ( 'should not accept `foo<bar` as a valid database name' , function ( ) {
118
+ it . skip ( 'should not accept `foo<bar` as a valid database name' , function ( ) {
116
119
assert . equal ( ns ( 'foo<bar' ) . validDatabaseName , false ) ;
117
120
} ) ;
118
- it . skip ( 'should not accept `foo>bar` as a valid database name' , function ( ) {
121
+ it . skip ( 'should not accept `foo>bar` as a valid database name' , function ( ) {
119
122
assert . equal ( ns ( 'foo>bar' ) . validDatabaseName , false ) ;
120
123
} ) ;
121
- it . skip ( 'should not accept `foo:bar` as a valid database name' , function ( ) {
124
+ it . skip ( 'should not accept `foo:bar` as a valid database name' , function ( ) {
122
125
assert . equal ( ns ( 'foo:bar' ) . validDatabaseName , false ) ;
123
126
} ) ;
124
- it . skip ( 'should not accept `foo|bar` as a valid database name' , function ( ) {
127
+ it . skip ( 'should not accept `foo|bar` as a valid database name' , function ( ) {
125
128
assert . equal ( ns ( 'foo|bar' ) . validDatabaseName , false ) ;
126
129
} ) ;
127
- it . skip ( 'should not accept `foo?bar` as a valid database name' , function ( ) {
130
+ it . skip ( 'should not accept `foo?bar` as a valid database name' , function ( ) {
128
131
assert . equal ( ns ( 'foo?bar' ) . validDatabaseName , false ) ;
129
132
} ) ;
130
133
} ) ;
131
134
132
- describe ( 'collection name validation' , function ( ) {
133
- it ( 'should accept `a.b` as valid' , function ( ) {
135
+ describe ( 'collection name validation' , function ( ) {
136
+ it ( 'should accept `a.b` as valid' , function ( ) {
134
137
assert . equal ( ns ( 'a.b' ) . validCollectionName , true ) ;
135
138
} ) ;
136
- it ( 'should accept `a.b` as valid' , function ( ) {
139
+ it ( 'should accept `a.b` as valid' , function ( ) {
137
140
assert . equal ( ns ( 'a.b' ) . validCollectionName , true ) ;
138
141
} ) ;
139
- it ( 'should accept `a.b.` as valid' , function ( ) {
142
+ it ( 'should accept `a.b.` as valid' , function ( ) {
140
143
assert . equal ( ns ( 'a.b.' ) . validCollectionName , true ) ;
141
144
} ) ;
142
- it ( 'should accept `a.b` as valid' , function ( ) {
145
+ it ( 'should accept `a.b` as valid' , function ( ) {
143
146
assert . equal ( ns ( 'a.b' ) . validCollectionName , true ) ;
144
147
} ) ;
145
- it ( 'should accept `a.b.` as valid' , function ( ) {
148
+ it ( 'should accept `a.b.` as valid' , function ( ) {
146
149
assert . equal ( ns ( 'a.b.' ) . validCollectionName , true ) ;
147
150
} ) ;
148
- it ( 'should accept `a$b` as valid' , function ( ) {
151
+ it ( 'should accept `a$b` as valid' , function ( ) {
149
152
assert . equal ( ns ( 'a$b' ) . validCollectionName , false ) ;
150
153
} ) ;
151
154
152
- it ( 'should not accept `a.` as valid' , function ( ) {
155
+ it ( 'should not accept `a.` as valid' , function ( ) {
153
156
assert . equal ( ns ( 'a.' ) . validCollectionName , false ) ;
154
157
} ) ;
155
158
156
- it ( 'should not accept `$a` as valid' , function ( ) {
159
+ it ( 'should not accept `$a` as valid' , function ( ) {
157
160
assert . equal ( ns ( '$a' ) . validCollectionName , false ) ;
158
161
} ) ;
159
162
160
- it ( 'should not accept `` as valid' , function ( ) {
163
+ it ( 'should not accept `` as valid' , function ( ) {
161
164
assert . equal ( ns ( '' ) . validCollectionName , false ) ;
162
165
} ) ;
163
166
} ) ;
164
167
165
- describe ( 'database hash' , function ( ) {
166
- it ( 'should have the same value for `foo` and `foo`' , function ( ) {
168
+ describe ( 'database hash' , function ( ) {
169
+ it ( 'should have the same value for `foo` and `foo`' , function ( ) {
167
170
assert . equal ( ns ( 'foo' ) . databaseHash , ns ( 'foo' ) . databaseHash ) ;
168
171
} ) ;
169
- it ( 'should have the same value for `foo` and `foo.a`' , function ( ) {
172
+ it ( 'should have the same value for `foo` and `foo.a`' , function ( ) {
170
173
assert . equal ( ns ( 'foo' ) . databaseHash , ns ( 'foo.a' ) . databaseHash ) ;
171
174
} ) ;
172
- it ( 'should have the same value for `foo` and `foo.`' , function ( ) {
175
+ it ( 'should have the same value for `foo` and `foo.`' , function ( ) {
173
176
assert . equal ( ns ( 'foo' ) . databaseHash , ns ( 'foo.' ) . databaseHash ) ;
174
177
} ) ;
175
- it ( 'should have the same value for `` and ``' , function ( ) {
178
+ it ( 'should have the same value for `` and ``' , function ( ) {
176
179
assert . equal ( ns ( '' ) . databaseHash , ns ( '' ) . databaseHash ) ;
177
180
} ) ;
178
- it ( 'should have the same value for `` and `.a`' , function ( ) {
181
+ it ( 'should have the same value for `` and `.a`' , function ( ) {
179
182
assert . equal ( ns ( '' ) . databaseHash , ns ( '.a' ) . databaseHash ) ;
180
183
} ) ;
181
- it ( 'should have the same value for `` and `.`' , function ( ) {
184
+ it ( 'should have the same value for `` and `.`' , function ( ) {
182
185
assert . equal ( ns ( '' ) . databaseHash , ns ( '.' ) . databaseHash ) ;
183
186
} ) ;
184
- it ( 'should not have the same value for `foo` and `food`' , function ( ) {
187
+ it ( 'should not have the same value for `foo` and `food`' , function ( ) {
185
188
assert . notEqual ( ns ( 'foo' ) . databaseHash , ns ( 'food' ) . databaseHash ) ;
186
189
} ) ;
187
- it ( 'should not have the same value for `foo.` and `food`' , function ( ) {
190
+ it ( 'should not have the same value for `foo.` and `food`' , function ( ) {
188
191
assert . notEqual ( ns ( 'foo.' ) . databaseHash , ns ( 'food' ) . databaseHash ) ;
189
192
} ) ;
190
- it ( 'should not have the same value for `foo.d` and `food`' , function ( ) {
193
+ it ( 'should not have the same value for `foo.d` and `food`' , function ( ) {
191
194
assert . notEqual ( ns ( 'foo.d' ) . databaseHash , ns ( 'food' ) . databaseHash ) ;
192
195
} ) ;
193
196
} ) ;
194
197
195
- it ( 'should extract database names' , function ( ) {
198
+ it ( 'should extract database names' , function ( ) {
196
199
assert . equal ( ns ( 'foo' ) . database , ns ( 'foo' ) . database ) ;
197
200
assert . equal ( ns ( 'foo' ) . database , ns ( 'foo.a' ) . database ) ;
198
201
assert . equal ( ns ( 'foo.a' ) . database , ns ( 'foo.a' ) . database ) ;
@@ -228,10 +231,26 @@ describe('ns', function() {
228
231
assert . equal ( ns ( 'abc.' ) . database , 'abc' ) ;
229
232
} ) ;
230
233
231
- describe ( 'sorting' , function ( ) {
232
- it ( 'should sort them' , function ( ) {
233
- var names = [ 'admin' , 'canadian-things' , 'github' , 'local' , 'scope_stat' , 'statsd' , 'test' ] ;
234
- var expect = [ 'canadian-things' , 'github' , 'scope_stat' , 'statsd' , 'test' , 'admin' , 'local' ] ;
234
+ describe ( 'sorting' , function ( ) {
235
+ it ( 'should sort them' , function ( ) {
236
+ var names = [
237
+ 'admin' ,
238
+ 'canadian-things' ,
239
+ 'github' ,
240
+ 'local' ,
241
+ 'scope_stat' ,
242
+ 'statsd' ,
243
+ 'test' ,
244
+ ] ;
245
+ var expect = [
246
+ 'canadian-things' ,
247
+ 'github' ,
248
+ 'scope_stat' ,
249
+ 'statsd' ,
250
+ 'test' ,
251
+ 'admin' ,
252
+ 'local' ,
253
+ ] ;
235
254
ns . sort ( names ) ;
236
255
assert . deepEqual ( names , expect ) ;
237
256
} ) ;
0 commit comments