2022-12-04 22:27:41 +00:00
|
|
|
package mmkv
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func Test_loadVault(t *testing.T) {
|
|
|
|
file, err := os.Open("./testdata/mmkv.default")
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
2024-02-04 16:47:24 +00:00
|
|
|
v, err := loadVault(file, nil, "")
|
2022-12-04 22:27:41 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
assert.Equal(t, 2, len(v.Keys()))
|
|
|
|
|
2022-12-04 23:14:32 +00:00
|
|
|
val, err := v.GetString("world")
|
|
|
|
assert.Equal(t, "hello", val)
|
|
|
|
assert.NoError(t, err)
|
2022-12-04 22:27:41 +00:00
|
|
|
|
2022-12-04 23:14:32 +00:00
|
|
|
_, err = v.GetBytes("foo")
|
|
|
|
assert.Error(t, err)
|
2022-12-04 22:27:41 +00:00
|
|
|
}
|