forked from TrueCloudLab/frostfs-api-go
[#310] *: Implement string converters for enumerations
Implement `String` / `FromString` method pair in all levels of enum definitions. From now `String()` returns canonical protojson-compatible values. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
fdea892db7
commit
616b4b71a1
25 changed files with 1053 additions and 76 deletions
|
@ -240,3 +240,15 @@ func TestNewNodeInfo(t *testing.T) {
|
|||
require.EqualValues(t, netmap.UnspecifiedState, niV2.GetState())
|
||||
})
|
||||
}
|
||||
|
||||
func TestNodeState_String(t *testing.T) {
|
||||
toPtr := func(v NodeState) *NodeState {
|
||||
return &v
|
||||
}
|
||||
|
||||
testEnumStrings(t, new(NodeState), []enumStringItem{
|
||||
{val: toPtr(NodeStateOnline), str: "ONLINE"},
|
||||
{val: toPtr(NodeStateOffline), str: "OFFLINE"},
|
||||
{val: toPtr(0), str: "UNSPECIFIED"},
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue