コード例 #1
0
ファイル: common_ops.go プロジェクト: Piasy/BeegoTDDBootStrap
func initORM() {
	if ormInitiated {
		return
	}
	appConf, err := config.NewConfig("ini", "conf/app.conf")
	if err != nil {
		panic(err)
	}
	dbAddr := appConf.String("admin::dbAddr")
	dbUser := appConf.String("admin::dbUser")
	dbPass := appConf.String("admin::dbPass")
	controllers.ALI_YUN_AK_ID = appConf.String("admin::akId")
	controllers.ALI_YUN_AK_KEY = appConf.String("admin::akKey")
	controllers.QQ_OAUTH_CONSUMER_KEY = appConf.String("admin::qqOAuthConsumerKey")
	clientId := appConf.String("admin::clientId")
	clientSecret := appConf.String("admin::clientSecret")
	controllers.BASIC_AUTH_AUTHORIZATION = utils.Base64(clientId + ":" + clientSecret)

	controllers.VISITOR_TOKEN = appConf.String("admin::visitorToken")

	orm.RegisterDriver("mymysql", orm.DRMySQL)
	conn := fmt.Sprintf("%s:%s@tcp(%s)/beego_unit_test?charset=utf8mb4", dbUser, dbPass, dbAddr)
	orm.RegisterDataBase("default", "mysql", conn)
	ormInitiated = true
}
コード例 #2
0
func TestBase64(t *testing.T) {
	clientId := "test_client"
	clientSecret := "test_pass"
	assert.Equal(t, "dGVzdF9jbGllbnQ6dGVzdF9wYXNz", utils.Base64(clientId+":"+clientSecret))
}