init: dec-music 项目初始化
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package mmkv
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_loadVault(t *testing.T) {
|
||||
file, err := os.Open("./testdata/mmkv.default")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
v, err := loadVault(file, nil, "")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if len(v.Keys()) != 2 {
|
||||
t.Fatalf("keys len = %d, want 2", len(v.Keys()))
|
||||
}
|
||||
|
||||
val, err := v.GetString("world")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if val != "hello" {
|
||||
t.Fatalf("world = %q, want hello", val)
|
||||
}
|
||||
|
||||
if _, err = v.GetBytes("foo"); err == nil {
|
||||
t.Fatal("expected error for missing key foo")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user