forked from TrueCloudLab/frostfs-node
[#180] node: Refactor panics in unit test
* Replace panics in unit tests by require.NoError and t.Fatalf Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
This commit is contained in:
parent
91717d4b98
commit
221203beeb
30 changed files with 76 additions and 79 deletions
|
@ -2,10 +2,12 @@ package testutil
|
|||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"testing"
|
||||
|
||||
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uber.org/atomic"
|
||||
"golang.org/x/exp/rand"
|
||||
)
|
||||
|
@ -94,17 +96,16 @@ func (g *OverwriteObjGenerator) Next() *object.Object {
|
|||
return generateObjectWithOIDWithCIDWithSize(id, cid.ID{}, g.ObjSize)
|
||||
}
|
||||
|
||||
func AddressFromObject(obj *object.Object) oid.Address {
|
||||
func AddressFromObject(t testing.TB, obj *object.Object) oid.Address {
|
||||
var addr oid.Address
|
||||
if id, isSet := obj.ID(); isSet {
|
||||
addr.SetObject(id)
|
||||
} else {
|
||||
panic("object ID is not set")
|
||||
}
|
||||
if cid, isSet := obj.ContainerID(); isSet {
|
||||
addr.SetContainer(cid)
|
||||
} else {
|
||||
panic("container ID is not set")
|
||||
}
|
||||
|
||||
id, isSet := obj.ID()
|
||||
require.True(t, isSet, "object ID is not set")
|
||||
addr.SetObject(id)
|
||||
|
||||
cid, isSet := obj.ContainerID()
|
||||
require.True(t, isSet, "container ID is not set")
|
||||
addr.SetContainer(cid)
|
||||
|
||||
return addr
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue