forked from TrueCloudLab/frostfs-api-go
[#218] Support SplitInfo structure
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
707a0bcb35
commit
1fdeca84e1
11 changed files with 832 additions and 410 deletions
42
pkg/object/splitinfo_test.go
Normal file
42
pkg/object/splitinfo_test.go
Normal file
|
@ -0,0 +1,42 @@
|
|||
package object_test
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"testing"
|
||||
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestSplitInfo(t *testing.T) {
|
||||
s := object.NewSplitInfo()
|
||||
splitID := object.NewSplitID()
|
||||
lastPart := generateID()
|
||||
link := generateID()
|
||||
|
||||
s.SetSplitID(splitID)
|
||||
require.Equal(t, splitID, s.SplitID())
|
||||
|
||||
s.SetLastPart(lastPart)
|
||||
require.Equal(t, lastPart, s.LastPart())
|
||||
|
||||
s.SetLink(link)
|
||||
require.Equal(t, link, s.Link())
|
||||
|
||||
t.Run("to and from v2", func(t *testing.T) {
|
||||
v2 := s.ToV2()
|
||||
newS := object.NewSplitInfoFromV2(v2)
|
||||
|
||||
require.Equal(t, s, newS)
|
||||
})
|
||||
}
|
||||
|
||||
func generateID() *object.ID {
|
||||
var buf [32]byte
|
||||
_, _ = rand.Read(buf[:])
|
||||
|
||||
id := object.NewID()
|
||||
id.SetSHA256(buf)
|
||||
|
||||
return id
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue