Skip to content

Commit

Permalink
fix unit test
Browse files Browse the repository at this point in the history
Signed-off-by: Jianjun Liao <[email protected]>
  • Loading branch information
Leavrth committed Apr 23, 2024
1 parent 43c4283 commit ba57f2d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
7 changes: 6 additions & 1 deletion br/pkg/restore/split/mock_pd_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,13 @@ func (c *MockPDClientForSplit) setRegions(boundaries [][]byte) []*metapb.Region
StartKey: boundaries[i-1],
EndKey: boundaries[i],
}
p := &metapb.Peer{
Id: c.lastRegionID,
StoreId: 1,
}
c.Regions.SetRegion(&pdtypes.Region{
Meta: r,
Meta: r,
Leader: p,
})
ret = append(ret, r)
}
Expand Down
16 changes: 16 additions & 0 deletions br/pkg/restore/split/split_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,13 +504,21 @@ func TestPaginateScanRegion(t *testing.T) {
StartKey: []byte{1},
EndKey: []byte{2},
},
Leader: &metapb.Peer{
Id: 1,
StoreId: 1,
},
})
mockPDClient.Regions.SetRegion(&pdtypes.Region{
Meta: &metapb.Region{
Id: 4,
StartKey: []byte{4},
EndKey: []byte{5},
},
Leader: &metapb.Peer{
Id: 4,
StoreId: 1,
},
})

_, err = PaginateScanRegion(ctx, mockClient, []byte{1}, []byte{5}, 3)
Expand All @@ -525,13 +533,21 @@ func TestPaginateScanRegion(t *testing.T) {
StartKey: []byte{2},
EndKey: []byte{3},
},
Leader: &metapb.Peer{
Id: 2,
StoreId: 1,
},
},
{
Meta: &metapb.Region{
Id: 3,
StartKey: []byte{3},
EndKey: []byte{4},
},
Leader: &metapb.Peer{
Id: 3,
StoreId: 1,
},
},
}
mockPDClient.scanRegions.beforeHook = func() {
Expand Down

0 comments on commit ba57f2d

Please sign in to comment.