package test

import (
	"log"
	"time"
	_ "time/tzdata"

	"github.com/pingcap/jira-bot/pkg/config"

	larkconf "github.com/larksuite/oapi-sdk-go/core/config"
	"github.com/pingcap/jira-bot/model"
	"gorm.io/gorm"
)

func helperInit() {
	loc, err := time.LoadLocation("Asia/Shanghai")
	if err != nil {
		log.Fatal(err)
	}
	time.Local = loc // -> this is setting the global timezone
	config.InitConfig("config-test", "yml", "../etc")
	model.SetRulePath("../etc/rules.json")
	err = model.InitApp()
	if err != nil {
		log.Fatal(err)
	}
}

func getDB() *gorm.DB {
	return model.GetApp().DB
}

func getLarkConfig() *larkconf.Config {
	return model.GetApp().LarkConf
}

func getRules() *model.NotificationRules {
	return &model.GetApp().NotificationRules
}
