From 993fa9ab5754d820fbaa0ce53a2ea2b9c66772a0 Mon Sep 17 00:00:00 2001 From: yanghao05 Date: Sat, 6 May 2023 15:50:16 +0800 Subject: [PATCH] add load providers for testing cases --- root.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/root.go b/root.go index 0cadefe..7a6fae7 100644 --- a/root.go +++ b/root.go @@ -25,11 +25,18 @@ func Serve(providers container.Providers, opts ...Option) error { for _, opt := range opts { opt(rootCmd) } + if err := LoadProviders(cfgFile, providers); err != nil { + return err + } withMigrationCommand(rootCmd) withModelCommand(rootCmd) withSeederCommand(rootCmd) + return rootCmd.Execute() +} + +func LoadProviders(cfgFile string, providers container.Providers) error { // parse config files configure, err := config.Load(cfgFile) if err != nil { @@ -39,8 +46,7 @@ func Serve(providers container.Providers, opts ...Option) error { if err := providers.Provide(configure); err != nil { return err } - - return rootCmd.Execute() + return nil } type Option func(*cobra.Command)