forked from TrueCloudLab/frostfs-api-go
[#302] pkg/session: Convert nil Token
to nil message
Document that `Token.ToV2` method return `nil` when called on `nil`. Document that `NewTokenFromV2` 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
2d7a658059
commit
707776976a
2 changed files with 21 additions and 0 deletions
|
@ -17,6 +17,8 @@ type Token session.SessionToken
|
|||
|
||||
// NewTokenFromV2 wraps session.SessionToken message structure
|
||||
// into Token.
|
||||
//
|
||||
// Nil session.SessionToken converts to nil.
|
||||
func NewTokenFromV2(tV2 *session.SessionToken) *Token {
|
||||
return (*Token)(tV2)
|
||||
}
|
||||
|
@ -27,6 +29,8 @@ func NewToken() *Token {
|
|||
}
|
||||
|
||||
// ToV2 converts Token to session.SessionToken message structure.
|
||||
//
|
||||
// Nil Token converts to nil.
|
||||
func (t *Token) ToV2() *session.SessionToken {
|
||||
return (*session.SessionToken)(t)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue