frostfs-sdk-go/netmap/node_info_test.go
Evgenii Stratonikov 3d6b5d807b [#315] netmap: Add maintenance node state
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2022-09-19 16:49:27 +04:00

47 lines
909 B
Go

package netmap
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestNodeInfo_SetAttribute(t *testing.T) {
var n NodeInfo
const key = "some key"
val := "some value"
require.Zero(t, n.Attribute(val))
n.SetAttribute(key, val)
require.Equal(t, val, n.Attribute(key))
val = "some other value"
n.SetAttribute(key, val)
require.Equal(t, val, n.Attribute(key))
}
func TestNodeInfo_Status(t *testing.T) {
var n NodeInfo
require.False(t, n.IsOnline())
require.False(t, n.IsOffline())
require.False(t, n.IsMaintenance())
n.SetOnline()
require.True(t, n.IsOnline())
require.False(t, n.IsOffline())
require.False(t, n.IsMaintenance())
n.SetOffline()
require.True(t, n.IsOffline())
require.False(t, n.IsOnline())
require.False(t, n.IsMaintenance())
n.SetMaintenance()
require.True(t, n.IsMaintenance())
require.False(t, n.IsOnline())
require.False(t, n.IsOffline())
}