forked from TrueCloudLab/frostfs-api-go
c0f3ac51d4
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
46 lines
869 B
Go
46 lines
869 B
Go
package refs_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/nspcc-dev/neofs-api-go/v2/refs"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestAddressJSON(t *testing.T) {
|
|
a := generateAddress([]byte{1}, []byte{2})
|
|
|
|
data, err := a.MarshalJSON()
|
|
require.NoError(t, err)
|
|
|
|
a2 := new(refs.Address)
|
|
require.NoError(t, a2.UnmarshalJSON(data))
|
|
|
|
require.Equal(t, a, a2)
|
|
}
|
|
|
|
func TestObjectIDJSON(t *testing.T) {
|
|
o := new(refs.ObjectID)
|
|
o.SetValue([]byte{1})
|
|
|
|
data, err := o.MarshalJSON()
|
|
require.NoError(t, err)
|
|
|
|
o2 := new(refs.ObjectID)
|
|
require.NoError(t, o2.UnmarshalJSON(data))
|
|
|
|
require.Equal(t, o, o2)
|
|
}
|
|
|
|
func TestContainerIDJSON(t *testing.T) {
|
|
cid := new(refs.ContainerID)
|
|
cid.SetValue([]byte{1})
|
|
|
|
data, err := cid.MarshalJSON()
|
|
require.NoError(t, err)
|
|
|
|
cid2 := new(refs.ContainerID)
|
|
require.NoError(t, cid2.UnmarshalJSON(data))
|
|
|
|
require.Equal(t, cid, cid2)
|
|
}
|