@@ -747,6 +747,47 @@ func TestReadRowsError(t *testing.T) {
747
747
}
748
748
}
749
749
750
+ func TestReadRowsErrorOnEmptyRegex (t * testing.T ) {
751
+ ctx := context .Background ()
752
+ s := & server {
753
+ tables : make (map [string ]* table ),
754
+ }
755
+ newTbl := btapb.Table {
756
+ ColumnFamilies : map [string ]* btapb.ColumnFamily {
757
+ "cf0" : {GcRule : & btapb.GcRule {Rule : & btapb.GcRule_MaxNumVersions {MaxNumVersions : 1 }}},
758
+ },
759
+ }
760
+ tblInfo , err := s .CreateTable (ctx , & btapb.CreateTableRequest {Parent : "cluster" , TableId : "t" , Table : & newTbl })
761
+ if err != nil {
762
+ t .Fatalf ("Creating table: %v" , err )
763
+ }
764
+ mreq := & btpb.MutateRowRequest {
765
+ TableName : tblInfo .Name ,
766
+ RowKey : []byte ("row" ),
767
+ Mutations : []* btpb.Mutation {{
768
+ Mutation : & btpb.Mutation_SetCell_ {SetCell : & btpb.Mutation_SetCell {
769
+ FamilyName : "cf0" ,
770
+ ColumnQualifier : []byte ("col" ),
771
+ TimestampMicros : 1000 ,
772
+ Value : []byte {},
773
+ }},
774
+ }},
775
+ }
776
+ if _ , err := s .MutateRow (ctx , mreq ); err != nil {
777
+ t .Fatalf ("Populating table: %v" , err )
778
+ }
779
+
780
+ mock := & MockReadRowsServer {}
781
+ req := & btpb.ReadRowsRequest {
782
+ TableName : tblInfo .Name , Filter : & btpb.RowFilter {
783
+ Filter : & btpb.RowFilter_RowKeyRegexFilter {RowKeyRegexFilter : []byte ("" )},
784
+ }, // Empty regexes should be rejected.
785
+ }
786
+ if err = s .ReadRows (req , mock ); err == nil {
787
+ t .Fatal ("ReadRows got no error, want error" )
788
+ }
789
+ }
790
+
750
791
func TestReadRowsAfterDeletion (t * testing.T ) {
751
792
ctx := context .Background ()
752
793
s := & server {
0 commit comments