[#302] pkg/object: Convert nil Attribute
to nil message
Document that `Attribute.ToV2` method return `nil` when called on `nil`. Document that `NewAttributeFromV2` function return `nil` when called on `nil`. Write corresponding unit tests. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
5fda8ef796
commit
941b513eb3
2 changed files with 21 additions and 0 deletions
|
@ -8,6 +8,8 @@ import (
|
|||
type Attribute object.Attribute
|
||||
|
||||
// NewAttributeFromV2 wraps v2 Attribute message to Attribute.
|
||||
//
|
||||
// Nil object.Attribute converts to nil.
|
||||
func NewAttributeFromV2(aV2 *object.Attribute) *Attribute {
|
||||
return (*Attribute)(aV2)
|
||||
}
|
||||
|
@ -40,6 +42,8 @@ func (a *Attribute) SetValue(v string) {
|
|||
}
|
||||
|
||||
// ToV2 converts Attribute to v2 Attribute message.
|
||||
//
|
||||
// Nil Attribute converts to nil.
|
||||
func (a *Attribute) ToV2() *object.Attribute {
|
||||
return (*object.Attribute)(a)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue