[add] migrate store
This commit is contained in:
parent
5faf62a789
commit
a9e865ff41
3 changed files with 23 additions and 25 deletions
2
Makefile
2
Makefile
|
|
@ -9,7 +9,7 @@ COMMIT := $(shell git log | head -n 1 | awk '{print substr($$2, 0, 12)}')
|
|||
NOW := $(shell date +"%FT%T%z")
|
||||
|
||||
# ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
||||
TESTFOLDER := $(shell $(GO) list ./... | grep -E 'api|model|flow|script|fs|i18n|connector|query|plugin|cert|crypto|task|schedule|runtime|helper|utils|widget|importer' | grep -vE 'examples|tests*|config|widgets')
|
||||
TESTFOLDER := $(shell $(GO) list ./... | grep -E 'api|model|flow|script|fs|i18n|connector|query|plugin|cert|crypto|task|schedule|runtime|helper|utils|widget|importer|store' | grep -vE 'examples|tests*|config|widgets')
|
||||
TESTTAGS ?= ""
|
||||
|
||||
# TESTWIDGETS := $(shell $(GO) list ./widgets/...)
|
||||
|
|
|
|||
|
|
@ -11,26 +11,11 @@ import (
|
|||
func Load(cfg config.Config) error {
|
||||
exts := []string{"*.yao", "*.json", "*.jsonc"}
|
||||
return application.App.Walk("stores", func(root, file string, isdir bool) error {
|
||||
if isdir {
|
||||
return nil
|
||||
}
|
||||
|
||||
_, err := store.Load(file, share.ID(root, file))
|
||||
return err
|
||||
}, exts...)
|
||||
}
|
||||
|
||||
// // LoadFrom load from dir
|
||||
// func LoadFrom(dir string, prefix string) error {
|
||||
|
||||
// if share.DirNotExists(dir) {
|
||||
// return fmt.Errorf("%s does not exists", dir)
|
||||
// }
|
||||
|
||||
// err := share.Walk(dir, ".json", func(root, filename string) {
|
||||
// name := prefix + share.SpecName(root, filename)
|
||||
// content := share.ReadFile(filename)
|
||||
// _, err := gou.LoadStore(string(content), name)
|
||||
// if err != nil {
|
||||
// log.With(log.F{"root": root, "file": filename}).Error(err.Error())
|
||||
// }
|
||||
// })
|
||||
|
||||
// return err
|
||||
// }
|
||||
|
|
|
|||
|
|
@ -7,18 +7,31 @@ import (
|
|||
"github.com/yaoapp/gou/store"
|
||||
"github.com/yaoapp/yao/config"
|
||||
"github.com/yaoapp/yao/connector"
|
||||
"github.com/yaoapp/yao/test"
|
||||
)
|
||||
|
||||
func TestLoad(t *testing.T) {
|
||||
connector.Load(config.Conf)
|
||||
test.Prepare(t, config.Conf)
|
||||
defer test.Clean()
|
||||
loadConnectors(t)
|
||||
|
||||
Load(config.Conf)
|
||||
check(t)
|
||||
}
|
||||
|
||||
func check(t *testing.T) {
|
||||
keys := []string{}
|
||||
for key := range store.Pools {
|
||||
keys = append(keys, key)
|
||||
ids := map[string]bool{}
|
||||
for id := range store.Pools {
|
||||
ids[id] = true
|
||||
}
|
||||
assert.True(t, ids["cache"])
|
||||
assert.True(t, ids["data"])
|
||||
assert.True(t, ids["share"])
|
||||
}
|
||||
|
||||
func loadConnectors(t *testing.T) {
|
||||
err := connector.Load(config.Conf)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
assert.Equal(t, 3, len(keys))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue