forked from TrueCloudLab/frostfs-sdk-go
[#264] storagegroup: Fix out of range
It panicked when the previous members slice had capacity more than a new one because of incorrect slicing that led to `out of range`. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
5518b63432
commit
6ac9deabb8
2 changed files with 14 additions and 2 deletions
|
@ -181,3 +181,15 @@ func generateOIDList() []refs.ObjectID {
|
|||
|
||||
return mmV2
|
||||
}
|
||||
|
||||
func TestStorageGroup_SetMembers_DoubleSetting(t *testing.T) {
|
||||
var sg storagegroup.StorageGroup
|
||||
|
||||
mm := []oid.ID{oidtest.ID(), oidtest.ID(), oidtest.ID()} // cap is 3 at least
|
||||
sg.SetMembers(mm)
|
||||
|
||||
// the previous cap is more that a new length;
|
||||
// slicing should not lead to `out of range`
|
||||
// and apply update correctly
|
||||
sg.SetMembers(mm[:1])
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue