forked from TrueCloudLab/frostfs-api-go
[#302] pkg/object: 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
941b513eb3
commit
ff851215b0
2 changed files with 20 additions and 0 deletions
|
@ -17,6 +17,10 @@ func NewAttributeFromV2(aV2 *object.Attribute) *Attribute {
|
|||
// NewAttribute creates and initializes blank Attribute.
|
||||
//
|
||||
// Works similar as NewAttributeFromV2(new(Attribute)).
|
||||
//
|
||||
// Defaults:
|
||||
// - key: "";
|
||||
// - value: "".
|
||||
func NewAttribute() *Attribute {
|
||||
return NewAttributeFromV2(new(object.Attribute))
|
||||
}
|
||||
|
|
|
@ -64,3 +64,19 @@ func TestAttribute_ToV2(t *testing.T) {
|
|||
require.Nil(t, x.ToV2())
|
||||
})
|
||||
}
|
||||
|
||||
func TestNewAttribute(t *testing.T) {
|
||||
t.Run("default values", func(t *testing.T) {
|
||||
a := NewAttribute()
|
||||
|
||||
// check initial values
|
||||
require.Empty(t, a.Key())
|
||||
require.Empty(t, a.Value())
|
||||
|
||||
// convert to v2 message
|
||||
aV2 := a.ToV2()
|
||||
|
||||
require.Empty(t, aV2.GetKey())
|
||||
require.Empty(t, aV2.GetValue())
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue