[#106] test: Generate correct IDs for tests
All checks were successful
DCO action / DCO (pull_request) Successful in 1m13s
Tests and linters / Tests (1.23) (pull_request) Successful in 1m21s
Tests and linters / Tests (1.22) (pull_request) Successful in 1m23s
Tests and linters / Tests with -race (pull_request) Successful in 1m45s
Tests and linters / Lint (pull_request) Successful in 3m42s

Signed-off-by: Aleksey Savchuk <a.savchuk@yadro.com>
This commit is contained in:
Aleksey Savchuk 2024-08-26 14:13:20 +03:00
parent 33653962b7
commit 3f35301340
No known key found for this signature in database

View file

@ -1,6 +1,8 @@
package refstest
import (
crand "crypto/rand"
"crypto/sha256"
"math/rand"
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs"
@ -21,7 +23,10 @@ func GenerateOwnerID(empty bool) *refs.OwnerID {
m := new(refs.OwnerID)
if !empty {
m.SetValue([]byte{1, 2, 3})
id := make([]byte, 25)
_, _ = crand.Read(id)
m.SetValue(id)
}
return m
@ -42,7 +47,10 @@ func GenerateObjectID(empty bool) *refs.ObjectID {
m := new(refs.ObjectID)
if !empty {
m.SetValue([]byte{1, 2, 3})
id := make([]byte, sha256.Size)
_, _ = crand.Read(id)
m.SetValue(id)
}
return m
@ -65,7 +73,10 @@ func GenerateContainerID(empty bool) *refs.ContainerID {
m := new(refs.ContainerID)
if !empty {
m.SetValue([]byte{1, 2, 3})
id := make([]byte, sha256.Size)
_, _ = crand.Read(id)
m.SetValue(id)
}
return m
@ -100,8 +111,11 @@ func GenerateChecksum(empty bool) *refs.Checksum {
m := new(refs.Checksum)
if !empty {
m.SetType(1)
m.SetSum([]byte{1, 2, 3})
cs := make([]byte, sha256.Size)
_, _ = crand.Read(cs)
m.SetType(refs.SHA256)
m.SetSum(cs)
}
return m