move file store

This commit is contained in:
Asim Aslam
2020-10-17 14:50:05 +01:00
parent 916a2a1a99
commit 0ebf401c21
8 changed files with 5 additions and 694 deletions

View File

@@ -6,21 +6,14 @@ import (
"testing"
"github.com/micro/go-micro/v3/store"
"github.com/micro/go-micro/v3/store/file"
"github.com/micro/go-micro/v3/store/memory"
"github.com/stretchr/testify/assert"
)
func cleanup(db string, s store.Store) {
s.Close()
dir := filepath.Join(file.DefaultDir, db+"/")
os.RemoveAll(dir)
}
func TestRead(t *testing.T) {
cf := NewStore(file.NewStore())
cf := NewStore(memory.NewStore())
cf.Init()
cfInt := cf.(*cache)
defer cleanup(file.DefaultDatabase, cf)
_, err := cf.Read("key1")
assert.Error(t, err, "Unexpected record")
@@ -38,10 +31,9 @@ func TestRead(t *testing.T) {
}
func TestWrite(t *testing.T) {
cf := NewStore(file.NewStore())
cf := NewStore(memory.NewStore())
cf.Init()
cfInt := cf.(*cache)
defer cleanup(file.DefaultDatabase, cf)
cf.Write(&store.Record{
Key: "key1",
@@ -55,10 +47,9 @@ func TestWrite(t *testing.T) {
}
func TestDelete(t *testing.T) {
cf := NewStore(file.NewStore())
cf := NewStore(memory.NewStore())
cf.Init()
cfInt := cf.(*cache)
defer cleanup(file.DefaultDatabase, cf)
cf.Write(&store.Record{
Key: "key1",
@@ -78,10 +69,9 @@ func TestDelete(t *testing.T) {
}
func TestList(t *testing.T) {
cf := NewStore(file.NewStore())
cf := NewStore(memory.NewStore())
cf.Init()
cfInt := cf.(*cache)
defer cleanup(file.DefaultDatabase, cf)
keys, err := cf.List()
assert.NoError(t, err)