package permisgen import ( "Cold_Logistic/internal/pkg/common/global" "Cold_Logistic/internal/pkg/common/options" "Cold_Logistic/internal/server/infra/dao" "context" "gogs.baozhida.cn/Cold_Logistic_libs/pkg/contrib/database/myorm" "testing" ) func init() { options.OptInstance = &options.Options{ DB: &myorm.DBOption{ Dialect: "mysql", Host: "192.168.11.23", Port: 3306, Db: "cc_logistic", UserName: "cc_logistic", Password: "7MBaLDh8ZjBTHwCR", OtherParams: "charset=utf8mb4&parseTime=True&loc=Local", MaxIdleConn: 20, MaxOpenConn: 200, ConnMaxLifetime: 60, }, } global.CommonConnectRepoInst = global.NewCommonConnectsRepo(options.OptInstance) global.CommonConnectRepoInst.StoreDB = myorm.InitMysql(*options.OptInstance.DB) } func Test_Region(t *testing.T) { store := dao.NewDataStore(global.CommonConnectRepoInst.StoreDB) ctx := context.Background() err := store.InTx(ctx, func(ctx context.Context) error { all, err := store.Region().FindAll(context.Background()) if err != nil { return err } res := make([]*RegionFiled, 0) res = buildRegionTree(res, all) err = NewRegionGen(store).Run(ctx, res) if err != nil { return err } return nil }) if err != nil { t.Errorf("err: %v", err) return } t.Log("成功") }