File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -126,6 +126,34 @@ func TestEngineRecordAccessConcurrent(t *testing.T) {
126126 }
127127}
128128
129+ func TestNewEngineWithDefaultRoute (t * testing.T ) {
130+ e := NewEngineWithDefaultRoute ()
131+ stats := e .Stats ()
132+
133+ if len (stats ) != 1 {
134+ t .Fatalf ("expected 1 route, got %d" , len (stats ))
135+ }
136+
137+ r := stats [0 ]
138+ if r .GroupID != defaultGroupID {
139+ t .Fatalf ("expected group ID %d, got %d" , defaultGroupID , r .GroupID )
140+ }
141+ if ! bytes .Equal (r .Start , []byte ("" )) {
142+ t .Fatalf ("expected start of keyspace (empty slice), got %q" , r .Start )
143+ }
144+ if r .End != nil {
145+ t .Fatalf ("expected end of keyspace (nil), got %q" , r .End )
146+ }
147+
148+ route , ok := e .GetRoute ([]byte ("any-key" ))
149+ if ! ok {
150+ t .Fatal ("GetRoute should find the default route" )
151+ }
152+ if route .GroupID != defaultGroupID {
153+ t .Fatalf ("GetRoute: expected group ID %d, got %d" , defaultGroupID , route .GroupID )
154+ }
155+ }
156+
129157func assertRange (t * testing.T , r Route , start , end []byte ) {
130158 t .Helper ()
131159 if ! bytes .Equal (r .Start , start ) || ! bytes .Equal (r .End , end ) {
You can’t perform that action at this time.
0 commit comments