11var assert = require ( 'assert' ) ;
22var ns = require ( '..' ) ;
33
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 ( ) {
77 assert ( ns ( 'a' ) . normal ) ;
88 } ) ;
9- it ( 'should acccept `a.b`' , function ( ) {
9+ it ( 'should acccept `a.b`' , function ( ) {
1010 assert ( ns ( 'a.b' ) . normal ) ;
1111 } ) ;
12- it ( 'should acccept `a.b.c`' , function ( ) {
12+ it ( 'should acccept `a.b.c`' , function ( ) {
1313 assert ( ns ( 'a.b.c' ) . normal ) ;
1414 } ) ;
15- it ( 'should acccept `local.oplog.$main`' , function ( ) {
15+ it ( 'should acccept `local.oplog.$main`' , function ( ) {
1616 assert ( ns ( 'local.oplog.$main' ) . normal ) ;
1717 } ) ;
18- it ( 'should acccept `local.oplog.rs`' , function ( ) {
18+ it ( 'should acccept `local.oplog.rs`' , function ( ) {
1919 assert ( ns ( 'local.oplog.rs' ) . normal ) ;
2020 } ) ;
21- it ( 'should not acccept `a.b.$c`' , function ( ) {
21+ it ( 'should not acccept `a.b.$c`' , function ( ) {
2222 assert . equal ( ns ( 'a.b.$c' ) . normal , false ) ;
2323 } ) ;
24- it ( 'should not acccept `a.b.$.c`' , function ( ) {
24+ it ( 'should not acccept `a.b.$.c`' , function ( ) {
2525 assert . equal ( ns ( 'a.b.$.c' ) . normal , false ) ;
2626 } ) ;
2727 } ) ;
2828
29- it ( 'should identify oplog namespaces' , function ( ) {
29+ it ( 'should identify oplog namespaces' , function ( ) {
3030 assert . equal ( ns ( 'a' ) . oplog , false ) ;
3131 assert . equal ( ns ( 'a.b' ) . oplog , false ) ;
3232 assert ( ns ( 'local.oplog.rs' ) . oplog ) ;
@@ -35,164 +35,167 @@ describe('ns', function() {
3535 assert . equal ( ns ( 'local.oplog.$foo' ) . oplog , false ) ;
3636 } ) ;
3737
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 ( ) {
4040 assert . equal ( ns ( 'a.$.b' ) . special , false ) ;
4141 } ) ;
42- it ( 'should acccept `a.system.foo`' , function ( ) {
42+ it ( 'should acccept `a.system.foo`' , function ( ) {
4343 assert ( ns ( 'a.system.foo' ) . special ) ;
4444 } ) ;
45- it ( 'should acccept `a.enxcol_.foo`' , function ( ) {
45+ it ( 'should acccept `a.enxcol_.foo`' , function ( ) {
4646 assert ( ns ( 'a.enxcol_.foo' ) . special ) ;
4747 } ) ;
48- it ( 'should not accept `a.foo`' , function ( ) {
48+ it ( 'should not accept `a.foo`' , function ( ) {
4949 assert . equal ( ns ( 'a.foo' ) . special , false ) ;
5050 } ) ;
51- it ( 'should not accept `a.systemfoo`' , function ( ) {
51+ it ( 'should not accept `a.systemfoo`' , function ( ) {
5252 assert . equal ( ns ( 'a.systemfoo' ) . special , false ) ;
5353 } ) ;
54- it ( 'should not accept `a.foo.system.bar`' , function ( ) {
54+ it ( 'should not accept `a.foo.system.bar`' , function ( ) {
5555 assert . equal ( ns ( 'a.foo.system.bar' ) . special , false ) ;
5656 } ) ;
57- it ( 'should not accept `prefix__mdb_internal_suffix`' , function ( ) {
57+ it ( 'should not accept `prefix__mdb_internal_suffix`' , function ( ) {
5858 assert . equal ( ns ( 'prefix__mdb_internal_suffix' ) . special , false ) ;
5959 } ) ;
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+ ) ;
6265 } ) ;
63- it ( 'should not accept `prefix__mdb_internal_suffix`' , function ( ) {
66+ it ( 'should not accept `prefix__mdb_internal_suffix`' , function ( ) {
6467 assert . equal ( ns ( 'prefix__mdb_internal_' ) . special , false ) ;
6568 } ) ;
66- it ( 'should acccept `__mdb_internal_suffix`' , function ( ) {
69+ it ( 'should acccept `__mdb_internal_suffix`' , function ( ) {
6770 assert ( ns ( '__mdb_internal_suffix' ) . special ) ;
6871 } ) ;
6972 } ) ;
7073
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 ( ) {
7376 assert ( ns ( 'anyDB.enxcol_.' ) . system ) ;
7477 } ) ;
75- it ( 'should acccept `anyDB.system.` as system`' , function ( ) {
78+ it ( 'should acccept `anyDB.system.` as system`' , function ( ) {
7679 assert ( ns ( 'anyDB.system.' ) . system ) ;
7780 } ) ;
78- it ( 'should acccept `anyDB.system.anyCollSuffix` as system`' , function ( ) {
81+ it ( 'should acccept `anyDB.system.anyCollSuffix` as system`' , function ( ) {
7982 assert ( ns ( 'anyDB.system.anyCollSuffix' ) . system ) ;
8083 } ) ;
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 ) ;
8386 } ) ;
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 ) ;
8689 } ) ;
8790 // 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 ) ;
9093 } ) ;
91- it ( 'should acccept `anyDB.system.profile_anything as system`' , function ( ) {
94+ it ( 'should acccept `anyDB.system.profile_anything as system`' , function ( ) {
9295 assert ( ns ( 'anyDB.system.profile_anything' ) . system ) ;
9396 } ) ;
9497 } ) ;
9598
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 ( ) {
98101 assert . equal ( ns ( 'foo' ) . validDatabaseName , true ) ;
99102 } ) ;
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 ( ) {
101104 assert . equal ( ns ( 'foo/bar' ) . validDatabaseName , false ) ;
102105 } ) ;
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 ( ) {
104107 assert . equal ( ns ( 'foo bar' ) . validDatabaseName , false ) ;
105108 } ) ;
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 ( ) {
107110 assert . equal ( ns ( 'foo\\bar' ) . validDatabaseName , false ) ;
108111 } ) ;
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 ) ;
111114 } ) ;
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 ( ) {
113116 assert . equal ( ns ( 'foo*bar' ) . validDatabaseName , false ) ;
114117 } ) ;
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 ( ) {
116119 assert . equal ( ns ( 'foo<bar' ) . validDatabaseName , false ) ;
117120 } ) ;
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 ( ) {
119122 assert . equal ( ns ( 'foo>bar' ) . validDatabaseName , false ) ;
120123 } ) ;
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 ( ) {
122125 assert . equal ( ns ( 'foo:bar' ) . validDatabaseName , false ) ;
123126 } ) ;
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 ( ) {
125128 assert . equal ( ns ( 'foo|bar' ) . validDatabaseName , false ) ;
126129 } ) ;
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 ( ) {
128131 assert . equal ( ns ( 'foo?bar' ) . validDatabaseName , false ) ;
129132 } ) ;
130133 } ) ;
131134
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 ( ) {
134137 assert . equal ( ns ( 'a.b' ) . validCollectionName , true ) ;
135138 } ) ;
136- it ( 'should accept `a.b` as valid' , function ( ) {
139+ it ( 'should accept `a.b` as valid' , function ( ) {
137140 assert . equal ( ns ( 'a.b' ) . validCollectionName , true ) ;
138141 } ) ;
139- it ( 'should accept `a.b.` as valid' , function ( ) {
142+ it ( 'should accept `a.b.` as valid' , function ( ) {
140143 assert . equal ( ns ( 'a.b.' ) . validCollectionName , true ) ;
141144 } ) ;
142- it ( 'should accept `a.b` as valid' , function ( ) {
145+ it ( 'should accept `a.b` as valid' , function ( ) {
143146 assert . equal ( ns ( 'a.b' ) . validCollectionName , true ) ;
144147 } ) ;
145- it ( 'should accept `a.b.` as valid' , function ( ) {
148+ it ( 'should accept `a.b.` as valid' , function ( ) {
146149 assert . equal ( ns ( 'a.b.' ) . validCollectionName , true ) ;
147150 } ) ;
148- it ( 'should accept `a$b` as valid' , function ( ) {
151+ it ( 'should accept `a$b` as valid' , function ( ) {
149152 assert . equal ( ns ( 'a$b' ) . validCollectionName , false ) ;
150153 } ) ;
151154
152- it ( 'should not accept `a.` as valid' , function ( ) {
155+ it ( 'should not accept `a.` as valid' , function ( ) {
153156 assert . equal ( ns ( 'a.' ) . validCollectionName , false ) ;
154157 } ) ;
155158
156- it ( 'should not accept `$a` as valid' , function ( ) {
159+ it ( 'should not accept `$a` as valid' , function ( ) {
157160 assert . equal ( ns ( '$a' ) . validCollectionName , false ) ;
158161 } ) ;
159162
160- it ( 'should not accept `` as valid' , function ( ) {
163+ it ( 'should not accept `` as valid' , function ( ) {
161164 assert . equal ( ns ( '' ) . validCollectionName , false ) ;
162165 } ) ;
163166 } ) ;
164167
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 ( ) {
167170 assert . equal ( ns ( 'foo' ) . databaseHash , ns ( 'foo' ) . databaseHash ) ;
168171 } ) ;
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 ( ) {
170173 assert . equal ( ns ( 'foo' ) . databaseHash , ns ( 'foo.a' ) . databaseHash ) ;
171174 } ) ;
172- it ( 'should have the same value for `foo` and `foo.`' , function ( ) {
175+ it ( 'should have the same value for `foo` and `foo.`' , function ( ) {
173176 assert . equal ( ns ( 'foo' ) . databaseHash , ns ( 'foo.' ) . databaseHash ) ;
174177 } ) ;
175- it ( 'should have the same value for `` and ``' , function ( ) {
178+ it ( 'should have the same value for `` and ``' , function ( ) {
176179 assert . equal ( ns ( '' ) . databaseHash , ns ( '' ) . databaseHash ) ;
177180 } ) ;
178- it ( 'should have the same value for `` and `.a`' , function ( ) {
181+ it ( 'should have the same value for `` and `.a`' , function ( ) {
179182 assert . equal ( ns ( '' ) . databaseHash , ns ( '.a' ) . databaseHash ) ;
180183 } ) ;
181- it ( 'should have the same value for `` and `.`' , function ( ) {
184+ it ( 'should have the same value for `` and `.`' , function ( ) {
182185 assert . equal ( ns ( '' ) . databaseHash , ns ( '.' ) . databaseHash ) ;
183186 } ) ;
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 ( ) {
185188 assert . notEqual ( ns ( 'foo' ) . databaseHash , ns ( 'food' ) . databaseHash ) ;
186189 } ) ;
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 ( ) {
188191 assert . notEqual ( ns ( 'foo.' ) . databaseHash , ns ( 'food' ) . databaseHash ) ;
189192 } ) ;
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 ( ) {
191194 assert . notEqual ( ns ( 'foo.d' ) . databaseHash , ns ( 'food' ) . databaseHash ) ;
192195 } ) ;
193196 } ) ;
194197
195- it ( 'should extract database names' , function ( ) {
198+ it ( 'should extract database names' , function ( ) {
196199 assert . equal ( ns ( 'foo' ) . database , ns ( 'foo' ) . database ) ;
197200 assert . equal ( ns ( 'foo' ) . database , ns ( 'foo.a' ) . database ) ;
198201 assert . equal ( ns ( 'foo.a' ) . database , ns ( 'foo.a' ) . database ) ;
@@ -228,10 +231,26 @@ describe('ns', function() {
228231 assert . equal ( ns ( 'abc.' ) . database , 'abc' ) ;
229232 } ) ;
230233
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+ ] ;
235254 ns . sort ( names ) ;
236255 assert . deepEqual ( names , expect ) ;
237256 } ) ;
0 commit comments