From fa78a377874f892a9465014cb849f8f1d495238a Mon Sep 17 00:00:00 2001 From: Pavel Karpy Date: Mon, 27 Dec 2021 19:18:53 +0300 Subject: [PATCH] [#1059] control: Add unit test for `SetShardMode` Signed-off-by: Pavel Karpy --- pkg/services/control/service_test.go | 29 ++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/pkg/services/control/service_test.go b/pkg/services/control/service_test.go index eacb0322da..3c89fc7d58 100644 --- a/pkg/services/control/service_test.go +++ b/pkg/services/control/service_test.go @@ -120,3 +120,32 @@ func generateListShardsResponseBody() *control.ListShardsResponse_Body { return body } + +func TestSetShardModeRequest_Body_StableMarshal(t *testing.T) { + testStableMarshal(t, + generateSetShardModeRequestBody(), + new(control.SetShardModeRequest_Body), + func(m1, m2 protoMessage) bool { + return equalSetShardModeRequestBodies( + m1.(*control.SetShardModeRequest_Body), + m2.(*control.SetShardModeRequest_Body), + ) + }, + ) +} + +func generateSetShardModeRequestBody() *control.SetShardModeRequest_Body { + body := new(control.SetShardModeRequest_Body) + body.SetShardID([]byte{0, 1, 2, 3, 4}) + body.SetMode(control.ShardMode_READ_WRITE) + + return body +} + +func equalSetShardModeRequestBodies(b1, b2 *control.SetShardModeRequest_Body) bool { + if b1.GetMode() != b2.GetMode() || !bytes.Equal(b1.Shard_ID, b2.Shard_ID) { + return false + } + + return true +}