forked from TrueCloudLab/frostfs-api-go
[#130] sdk: Define object identifier type
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
edd0004b93
commit
a65db08608
2 changed files with 81 additions and 0 deletions
27
pkg/object/id_test.go
Normal file
27
pkg/object/id_test.go
Normal file
|
@ -0,0 +1,27 @@
|
|||
package object
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"crypto/sha256"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestIDV2(t *testing.T) {
|
||||
id := new(ID)
|
||||
|
||||
checksum := [sha256.Size]byte{}
|
||||
|
||||
_, err := rand.Read(checksum[:])
|
||||
require.NoError(t, err)
|
||||
|
||||
id.SetSHA256(checksum)
|
||||
|
||||
idV2 := id.ToV2()
|
||||
|
||||
id2, err := IDFromV2(idV2)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, id, id2)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue