From 18edc740ee7596e029a43135773f63b3cec0550f Mon Sep 17 00:00:00 2001 From: Evan Chen Date: Fri, 17 Dec 2021 16:42:14 +0800 Subject: [PATCH] update --- helper.go | 31 +++++++++++++++++++++++++++++++ main_test.go | 24 +----------------------- 2 files changed, 32 insertions(+), 23 deletions(-) create mode 100644 helper.go diff --git a/helper.go b/helper.go new file mode 100644 index 0000000..a98b345 --- /dev/null +++ b/helper.go @@ -0,0 +1,31 @@ +package app + +import ( + "github.com/spf13/viper" + "kumoly.io/kumoly/app/auth" + "kumoly.io/kumoly/app/control" + "kumoly.io/kumoly/app/email" + "kumoly.io/kumoly/app/history" + "kumoly.io/kumoly/app/server" + "kumoly.io/kumoly/app/store" + "kumoly.io/kumoly/app/system" + "kumoly.io/kumoly/app/task" +) + +func Default() *system.System { + store.Setup() + sys := system.New() + server := server.New(viper.GetString("name")) + + auth.Setup() + auth.SetDB(store.DB) + + sys.Inject(auth.Injector(server.API)) + sys.Append(server, auth.New(server), + &task.Service{}, + &history.Service{}, + &email.Service{}, + &control.Service{}, + ) + return sys +} diff --git a/main_test.go b/main_test.go index 5b6e62b..16e4d53 100644 --- a/main_test.go +++ b/main_test.go @@ -2,32 +2,10 @@ package app import ( "testing" - - "kumoly.io/kumoly/app/auth" - "kumoly.io/kumoly/app/control" - "kumoly.io/kumoly/app/email" - "kumoly.io/kumoly/app/history" - "kumoly.io/kumoly/app/server" - "kumoly.io/kumoly/app/store" - "kumoly.io/kumoly/app/system" - "kumoly.io/kumoly/app/task" ) func TestMain(t *testing.T) { - store.Setup() - sys := system.New() - server := server.New("app") - - auth.Setup() - auth.SetDB(store.DB) - - sys.Inject(auth.Injector(server.API)) - sys.Append(server, auth.New(server), - &task.Service{}, - &history.Service{}, - &email.Service{}, - &control.Service{}, - ) + sys := Default() go sys.Start() <-sys.Done()