2021-09-06 12:43:30 +00:00
|
|
|
package state_test
|
|
|
|
|
|
|
|
import (
|
2022-02-02 13:28:08 +00:00
|
|
|
"path/filepath"
|
2021-09-06 12:43:30 +00:00
|
|
|
"testing"
|
|
|
|
|
2023-03-07 13:38:26 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/state"
|
2021-09-06 12:43:30 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestPersistentStorage_UInt32(t *testing.T) {
|
2022-02-02 13:28:08 +00:00
|
|
|
storage, err := state.NewPersistentStorage(filepath.Join(t.TempDir(), ".storage"))
|
2021-09-06 12:43:30 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
defer storage.Close()
|
|
|
|
|
|
|
|
n, err := storage.UInt32([]byte("unset-value"))
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.EqualValues(t, 0, n)
|
|
|
|
|
|
|
|
err = storage.SetUInt32([]byte("foo"), 10)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
n, err = storage.UInt32([]byte("foo"))
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.EqualValues(t, 10, n)
|
|
|
|
}
|