go-mmkv/manager_test.go

35 lines
698 B
Go
Raw Permalink Normal View History

2022-12-04 22:27:41 +00:00
package mmkv
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestNewManager(t *testing.T) {
2024-02-04 16:47:24 +00:00
t.Run("Default", func(t *testing.T) {
mgr, err := NewManager("./testdata")
assert.NoError(t, err)
assert.NotNil(t, mgr)
2022-12-04 22:27:41 +00:00
2024-02-04 16:47:24 +00:00
vault, err := mgr.OpenVault("")
assert.NoError(t, err)
assert.NotNil(t, vault)
})
t.Run("Crypto", func(t *testing.T) {
mgr, err := NewManager("./testdata")
assert.NoError(t, err)
assert.NotNil(t, mgr)
vault, err := mgr.OpenVaultCrypto("crypto", "123456")
val, err := vault.GetString("world")
assert.NotNil(t, vault)
assert.Equal(t, "hello", val)
assert.NoError(t, err)
_, err = vault.GetBytes("foo")
assert.Error(t, err)
})
2022-12-04 22:27:41 +00:00
}