[#xx] test: Generate correct IDs for tests
Some checks failed
DCO action / DCO (pull_request) Failing after 1m8s
Tests and linters / Tests (1.23) (pull_request) Successful in 1m15s
Tests and linters / Tests (1.22) (pull_request) Successful in 1m18s
Tests and linters / Tests with -race (pull_request) Successful in 1m58s
Tests and linters / Lint (pull_request) Successful in 3m24s

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 f9ad60d418
No known key found for this signature in database

View file

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