diff --git a/Makefile b/Makefile index cb166dd8..d0151efc 100644 --- a/Makefile +++ b/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/...) diff --git a/store/store.go b/store/store.go index ee9f891c..35ae8313 100644 --- a/store/store.go +++ b/store/store.go @@ -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 -// } diff --git a/store/store_test.go b/store/store_test.go index d6c22b76..4cb51b01 100644 --- a/store/store_test.go +++ b/store/store_test.go @@ -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)) }