forked from TrueCloudLab/frostfs-api-go
[#302] pkg/container: Document default values set in NewAnnouncement
Document field values of instance constructed via `NewAnnouncement`. Assert the values in corresponding unit test. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
c54dee82be
commit
1863694b96
2 changed files with 21 additions and 0 deletions
|
@ -10,6 +10,11 @@ import (
|
||||||
type UsedSpaceAnnouncement container.UsedSpaceAnnouncement
|
type UsedSpaceAnnouncement container.UsedSpaceAnnouncement
|
||||||
|
|
||||||
// NewAnnouncement initialize empty UsedSpaceAnnouncement message.
|
// NewAnnouncement initialize empty UsedSpaceAnnouncement message.
|
||||||
|
//
|
||||||
|
// Defaults:
|
||||||
|
// - epoch: 0;
|
||||||
|
// - usedSpace: 0;
|
||||||
|
// - cid: nil.
|
||||||
func NewAnnouncement() *UsedSpaceAnnouncement {
|
func NewAnnouncement() *UsedSpaceAnnouncement {
|
||||||
return NewAnnouncementFromV2(new(container.UsedSpaceAnnouncement))
|
return NewAnnouncementFromV2(new(container.UsedSpaceAnnouncement))
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,6 +72,22 @@ func TestUsedSpaceAnnouncement_ToV2(t *testing.T) {
|
||||||
|
|
||||||
require.Nil(t, x.ToV2())
|
require.Nil(t, x.ToV2())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.Run("default values", func(t *testing.T) {
|
||||||
|
announcement := container.NewAnnouncement()
|
||||||
|
|
||||||
|
// check initial values
|
||||||
|
require.Zero(t, announcement.Epoch())
|
||||||
|
require.Zero(t, announcement.UsedSpace())
|
||||||
|
require.Nil(t, announcement.ContainerID())
|
||||||
|
|
||||||
|
// convert to v2 message
|
||||||
|
announcementV2 := announcement.ToV2()
|
||||||
|
|
||||||
|
require.Zero(t, announcementV2.GetEpoch())
|
||||||
|
require.Zero(t, announcementV2.GetUsedSpace())
|
||||||
|
require.Nil(t, announcementV2.GetContainerID())
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNewAnnouncementFromV2(t *testing.T) {
|
func TestNewAnnouncementFromV2(t *testing.T) {
|
||||||
|
|
Loading…
Reference in a new issue