Skip to content

Commit ec264ee

Browse files
committed
distribution: test default route
1 parent f8faf7e commit ec264ee

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

distribution/engine_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
129157
func assertRange(t *testing.T, r Route, start, end []byte) {
130158
t.Helper()
131159
if !bytes.Equal(r.Start, start) || !bytes.Equal(r.End, end) {

0 commit comments

Comments
 (0)