forked from TrueCloudLab/frostfs-api-go
Update structure with grpc subdir
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
6191903326
commit
60e9c3d0d3
40 changed files with 1624 additions and 1595 deletions
77
v2/container/grpc/marshal_test.go
Normal file
77
v2/container/grpc/marshal_test.go
Normal file
|
@ -0,0 +1,77 @@
|
|||
package container
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
netmap "github.com/nspcc-dev/neofs-api-go/v2/netmap/grpc"
|
||||
refs "github.com/nspcc-dev/neofs-api-go/v2/refs/grpc"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
var (
|
||||
cnr = &Container{
|
||||
OwnerId: &refs.OwnerID{Value: []byte("Owner")},
|
||||
Nonce: []byte("Salt"),
|
||||
BasicAcl: 505,
|
||||
Attributes: []*Container_Attribute{
|
||||
{
|
||||
Key: "Hello",
|
||||
Value: "World",
|
||||
},
|
||||
{
|
||||
Key: "Privet",
|
||||
Value: "Mir",
|
||||
},
|
||||
},
|
||||
PlacementPolicy: &netmap.PlacementPolicy{
|
||||
ReplFactor: 4,
|
||||
FilterGroups: []*netmap.PlacementPolicy_FilterGroup{
|
||||
{
|
||||
Selectors: []*netmap.PlacementPolicy_FilterGroup_Selector{
|
||||
{
|
||||
Count: 1,
|
||||
Key: "Node",
|
||||
},
|
||||
},
|
||||
Filters: []*netmap.PlacementPolicy_FilterGroup_Filter{
|
||||
{
|
||||
Key: "City",
|
||||
},
|
||||
{
|
||||
Key: "Datacenter",
|
||||
},
|
||||
},
|
||||
Exclude: []uint32{4, 5, 6},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
func TestContainer_StableMarshal(t *testing.T) {
|
||||
newCnr := new(Container)
|
||||
|
||||
wire, err := cnr.StableMarshal(nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
err = newCnr.Unmarshal(wire)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, cnr, newCnr)
|
||||
}
|
||||
|
||||
func TestPutRequest_Body_StableMarshal(t *testing.T) {
|
||||
expectedBody := new(PutRequest_Body)
|
||||
expectedBody.Container = cnr
|
||||
expectedBody.PublicKey = []byte{1, 2, 3, 4}
|
||||
expectedBody.Signature = []byte{5, 6, 7, 8}
|
||||
|
||||
wire, err := expectedBody.StableMarshal(nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
gotBody := new(PutRequest_Body)
|
||||
err = gotBody.Unmarshal(wire)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, expectedBody, gotBody)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue