forked from TrueCloudLab/frostfs-api-go
[#302] pkg/container: Document default values set in NewAttribute
Document field values of instance constructed via `NewAttribute`. Assert the values in corresponding unit test. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
8b7a433864
commit
3984353d37
2 changed files with 18 additions and 0 deletions
|
@ -9,6 +9,11 @@ type (
|
||||||
Attributes []*Attribute
|
Attributes []*Attribute
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// NewAttribute creates and initializes blank Attribute.
|
||||||
|
//
|
||||||
|
// Defaults:
|
||||||
|
// - key: "";
|
||||||
|
// - value: "".
|
||||||
func NewAttribute() *Attribute {
|
func NewAttribute() *Attribute {
|
||||||
return NewAttributeFromV2(new(container.Attribute))
|
return NewAttributeFromV2(new(container.Attribute))
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,19 @@ func TestAttribute(t *testing.T) {
|
||||||
require.Nil(t, x.ToV2())
|
require.Nil(t, x.ToV2())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.Run("default values", func(t *testing.T) {
|
||||||
|
attr := container.NewAttribute()
|
||||||
|
|
||||||
|
// check initial values
|
||||||
|
require.Empty(t, attr.Key())
|
||||||
|
require.Empty(t, attr.Value())
|
||||||
|
|
||||||
|
// convert to v2 message
|
||||||
|
attrV2 := attr.ToV2()
|
||||||
|
require.Empty(t, attrV2.GetKey())
|
||||||
|
require.Empty(t, attrV2.GetValue())
|
||||||
|
})
|
||||||
|
|
||||||
const (
|
const (
|
||||||
key = "key"
|
key = "key"
|
||||||
value = "value"
|
value = "value"
|
||||||
|
|
Loading…
Reference in a new issue