Exemple #1
0
func init() {

	cmd, err := notify.NewCmd("telegram-cli", "-C")

	if err != nil {
		log.Fatal("NewCmd error", err)
	}

	botConf = Conf{
		Limit: 10,
		Url:   "localhost",
		Rpms:  500,
		Cmd:   cmd,
	}

	//Init Data Mapper
	c, err := beeconf.NewConfig("ini", "../../conf/app.conf")

	if err != nil {
		log.Fatal(err)
	}

	TestConfig, err := conf.Initialize("test", c)
	if err != nil {
		log.Fatal(err)
	}

	if err := M.DbOpen(TestConfig.Db); err != nil {
		log.Fatal(err)
	}

	M.PrepareTables(&M.Cand{})
	Tfn, _ := i18n.Tfunc("en-us", "en-us", "en-us")
	M.T = Tfn
}
Exemple #2
0
func init() {
	var err error
	// read main config file
	AppConfig, err = conf.Initialize(beego.AppConfig.String("runmode"), beego.AppConfig)
	if err != nil {
		log.Fatal(err)
	}
	// Open connection to DB and pass connection to DataMapper
	if err := M.DbOpen(AppConfig.Db); err != nil {
		log.Fatal(err)
	}

	// Register and Prepare app models in our DataMapper
	M.PrepareTables(&M.User{}, &M.Cand{}, &M.Rat{}, &M.Crit{}, &M.Dep{}, &M.Comment{}, &M.Role{}, &M.File{}, &M.Contact{}, &M.Mail{}, &M.Lang{})

	if err := logger.Initialize(AppConfig.Log); err != nil {
		log.Fatal(err)
	}
}
Exemple #3
0
func TestMain(m *testing.M) {

	c, err := config.NewConfig("ini", "../conf/app.conf")

	if err != nil {
		log.Fatal(err)
	}

	TestConfig, err := conf.Initialize("test", c)
	if err != nil {
		log.Fatal(err)
	}

	if err := DbOpen(TestConfig.Db); err != nil {
		log.Fatal(err)
	}

	defer DbClose()

	PrepareTables(&User{}, &Cand{}, &Rat{}, &Crit{}, &Dep{}, &Comment{}, &Role{}, &Contact{}, &Mail{})

	err = ClearTestData(&User{}, &Crit{}, &Rat{}, &Dep{})
	if err != nil {
		log.Fatal(err)
	}

	err = InsertTestData("../migrations/test_data/data.sql")
	if err != nil {
		log.Fatal(err)
	}

	i18n.MustLoadTranslationFile("../langs/en-US.all.json")
	T, _ = i18n.Tfunc("en-US", "en-US", "en-US")

	exitCode := m.Run()

	os.Exit(exitCode)
}
Exemple #4
0
func init() {
	c, err := beeconf.NewConfig("ini", "../../conf/app.conf")

	if err != nil {
		log.Fatal(err)
	}

	TestConfig, err := conf.Initialize("test", c)
	if err != nil {
		log.Fatal(err)
	}

	if err := M.DbOpen(TestConfig.Db); err != nil {
		log.Fatal(err)
	}

	M.PrepareTables(&M.Mail{})
	db = M.GetDM()
	Tfn, _ := i18n.Tfunc("en-us", "en-us", "en-us")
	M.T = Tfn

	mailSt = MailStore{db, 3}
}
Exemple #5
0
func init() {
	testServer.Start()

	auth := aws.Auth{
		AccessKey: "abc",
		SecretKey: "123",
	}

	c, err := config.NewConfig("ini", "../../conf/app.conf")

	if err != nil {
		log.Fatal(err)
	}

	TestConfig, err := conf.Initialize("test", c)

	if err != nil {
		log.Fatal(err)
	}

	dbConf := TestConfig.Db

	db := DBConf{dbConf.Postgres.Host, dbConf.Postgres.User, dbConf.Postgres.Pass, dbConf.Postgres.Database}
	awsl := Aws{auth, "git-lab", "hrkb_backups/"}

	bp = NewBackup(&db, &awsl, "test_backup/", 3, 10, 15, 10)

	err = removeTestData()
	if err != nil {
		log.Fatal(err)
	}
	bp.AwsCon = s3.New(awsl.Auth, aws.Region{Name: "faux-region-1", S3Endpoint: testServer.URL})
	err = createTestData()
	if err != nil {
		log.Fatal(err)
	}
}