@@ -214,41 +214,41 @@ describe('Bigtable/Table', function() {
214214 } ) ;
215215 } ) ;
216216
217- describe ( 'createPrefixRange_ ' , function ( ) {
217+ describe ( 'createPrefixRange ' , function ( ) {
218218 it ( 'should create a range from the prefix' , function ( ) {
219- assert . deepStrictEqual ( Table . createPrefixRange_ ( 'start' ) , {
219+ assert . deepStrictEqual ( table . createPrefixRange ( 'start' ) , {
220220 start : 'start' ,
221221 end : {
222222 value : 'staru' ,
223223 inclusive : false ,
224224 } ,
225225 } ) ;
226226
227- assert . deepStrictEqual ( Table . createPrefixRange_ ( 'X\xff' ) , {
227+ assert . deepStrictEqual ( table . createPrefixRange ( 'X\xff' ) , {
228228 start : 'X\xff' ,
229229 end : {
230230 value : 'Y' ,
231231 inclusive : false ,
232232 } ,
233233 } ) ;
234234
235- assert . deepStrictEqual ( Table . createPrefixRange_ ( 'xoo\xff' ) , {
235+ assert . deepStrictEqual ( table . createPrefixRange ( 'xoo\xff' ) , {
236236 start : 'xoo\xff' ,
237237 end : {
238238 value : 'xop' ,
239239 inclusive : false ,
240240 } ,
241241 } ) ;
242242
243- assert . deepStrictEqual ( Table . createPrefixRange_ ( 'a\xffb' ) , {
243+ assert . deepStrictEqual ( table . createPrefixRange ( 'a\xffb' ) , {
244244 start : 'a\xffb' ,
245245 end : {
246246 value : 'a\xffc' ,
247247 inclusive : false ,
248248 } ,
249249 } ) ;
250250
251- assert . deepStrictEqual ( Table . createPrefixRange_ ( 'com.google.' ) , {
251+ assert . deepStrictEqual ( table . createPrefixRange ( 'com.google.' ) , {
252252 start : 'com.google.' ,
253253 end : {
254254 value : 'com.google/' ,
@@ -258,15 +258,15 @@ describe('Bigtable/Table', function() {
258258 } ) ;
259259
260260 it ( 'should create an inclusive bound when the prefix is empty' , function ( ) {
261- assert . deepStrictEqual ( Table . createPrefixRange_ ( '\xff' ) , {
261+ assert . deepStrictEqual ( table . createPrefixRange ( '\xff' ) , {
262262 start : '\xff' ,
263263 end : {
264264 value : '' ,
265265 inclusive : true ,
266266 } ,
267267 } ) ;
268268
269- assert . deepStrictEqual ( Table . createPrefixRange_ ( '' ) , {
269+ assert . deepStrictEqual ( table . createPrefixRange ( '' ) , {
270270 start : '' ,
271271 end : {
272272 value : '' ,
@@ -561,13 +561,99 @@ describe('Bigtable/Table', function() {
561561 table . createReadStream ( options ) ;
562562 } ) ;
563563
564+ it ( 'should throw if ranges and start is set together' , function ( ) {
565+ const options = {
566+ ranges : [
567+ {
568+ start : 'a' ,
569+ end : 'b' ,
570+ } ,
571+ {
572+ start : 'c' ,
573+ end : 'd' ,
574+ } ,
575+ ] ,
576+ start : 'a' ,
577+ } ;
578+ assert . throws ( function ( ) {
579+ table . createReadStream ( options , assert . ifError ) ;
580+ } , / s t a r t \/ e n d s h o u l d b e u s e d e x c l u s i v e l y t o r a n g e s \/ p r e f i x \/ p r e f i x e s \. / ) ;
581+ } ) ;
582+
583+ it ( 'should throw if ranges and end is set together' , function ( ) {
584+ const options = {
585+ ranges : [
586+ {
587+ start : 'a' ,
588+ end : 'b' ,
589+ } ,
590+ {
591+ start : 'c' ,
592+ end : 'd' ,
593+ } ,
594+ ] ,
595+ end : 'a' ,
596+ } ;
597+ assert . throws ( function ( ) {
598+ table . createReadStream ( options , assert . ifError ) ;
599+ } , / s t a r t \/ e n d s h o u l d b e u s e d e x c l u s i v e l y t o r a n g e s \/ p r e f i x \/ p r e f i x e s \. / ) ;
600+ } ) ;
601+
602+ it ( 'should throw if ranges and prefix is set together' , function ( ) {
603+ const options = {
604+ ranges : [
605+ {
606+ start : 'a' ,
607+ end : 'b' ,
608+ } ,
609+ {
610+ start : 'c' ,
611+ end : 'd' ,
612+ } ,
613+ ] ,
614+ prefix : 'a' ,
615+ } ;
616+ assert . throws ( function ( ) {
617+ table . createReadStream ( options , assert . ifError ) ;
618+ } , / p r e f i x s h o u l d b e u s e d e x c l u s i v e l y t o r a n g e s \/ s t a r t \/ e n d \/ p r e f i x e s \. / ) ;
619+ } ) ;
620+
621+ it ( 'should throw if ranges and prefixes is set together' , function ( ) {
622+ const options = {
623+ ranges : [
624+ {
625+ start : 'a' ,
626+ end : 'b' ,
627+ } ,
628+ {
629+ start : 'c' ,
630+ end : 'd' ,
631+ } ,
632+ ] ,
633+ prefixes : [ { prefix : 'a' } ] ,
634+ } ;
635+ assert . throws ( function ( ) {
636+ table . createReadStream ( options , assert . ifError ) ;
637+ } , / p r e f i x e s s h o u l d b e u s e d e x c l u s i v e l y t o r a n g e s \/ s t a r t \/ e n d \/ p r e f i x \. / ) ;
638+ } ) ;
639+
640+ it ( 'should throw if prefix and start is set together' , function ( ) {
641+ const options = {
642+ start : 'a' ,
643+ prefix : 'a' ,
644+ } ;
645+ assert . throws ( function ( ) {
646+ table . createReadStream ( options , assert . ifError ) ;
647+ } , / s t a r t \/ e n d s h o u l d b e u s e d e x c l u s i v e l y t o r a n g e s \/ p r e f i x \/ p r e f i x e s \. / ) ;
648+ } ) ;
649+
564650 describe ( 'prefixes' , function ( ) {
565651 beforeEach ( function ( ) {
566652 FakeFilter . createRange = common . util . noop ;
567653 } ) ;
568654
569655 afterEach ( function ( ) {
570- Table . createPrefixRange_ . restore ( ) ;
656+ table . createPrefixRange . restore ( ) ;
571657 } ) ;
572658
573659 it ( 'should transform the prefix into a range' , function ( done ) {
@@ -580,7 +666,7 @@ describe('Bigtable/Table', function() {
580666 const fakePrefix = 'abc' ;
581667
582668 const prefixSpy = sinon
583- . stub ( Table , 'createPrefixRange_ ' )
669+ . stub ( table , 'createPrefixRange ' )
584670 . callsFake ( function ( ) {
585671 return fakePrefixRange ;
586672 } ) ;
@@ -614,7 +700,7 @@ describe('Bigtable/Table', function() {
614700 { start : 'def' , end : 'deg' } ,
615701 ] ;
616702 const prefixSpy = sinon
617- . stub ( Table , 'createPrefixRange_ ' )
703+ . stub ( table , 'createPrefixRange ' )
618704 . callsFake ( function ( ) {
619705 const callIndex = prefixSpy . callCount - 1 ;
620706 return prefixRanges [ callIndex ] ;
0 commit comments