forked from TrueCloudLab/frostfs-node
[#798] util/state: Implement persistent storage for application state
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
b4378f7c11
commit
7f074a775e
2 changed files with 97 additions and 0 deletions
26
pkg/util/state/storage_test.go
Normal file
26
pkg/util/state/storage_test.go
Normal file
|
@ -0,0 +1,26 @@
|
|||
package state_test
|
||||
|
||||
import (
|
||||
"path"
|
||||
"testing"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/pkg/util/state"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestPersistentStorage_UInt32(t *testing.T) {
|
||||
storage, err := state.NewPersistentStorage(path.Join(t.TempDir(), ".storage"))
|
||||
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)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue