Ejemplo n.º 1
0
func TestMain(m *testing.M) {
	// Тестовый сервер для вызова Login
	credForServer = &cred{}
	hf := func(c *gin.Context) {
		lastUser, lastOk = Login(c, credForServer.name, credForServer.pass)
	}
	loginServer = apptesting.NewServer(hf)

	// Тестовый сервер для вызова User.AutoLogin
	userForServer = &User{}
	hf = func(c *gin.Context) {
		userForServer.AutoLogin(c)
	}
	autoLoginServer = apptesting.NewServer(hf)

	// Тестовый сервер для вызова FromContext
	hf = func(c *gin.Context) {
		lastUser, lastOk = FromContext(c)
	}
	fromCtxServer = apptesting.NewServer(hf)

	// Тестовый сервер для вызова Logout
	hf = func(c *gin.Context) {
		Logout(c)
	}
	logoutServer = apptesting.NewServer(hf)
	models.DB.LogMode(false)
	os.Exit(m.Run())
}
Ejemplo n.º 2
0
func TestMain(m *testing.M) {
	hf := func(c *gin.Context) {
		Register(c)
		cu, ok = user.FromContext(c)
	}
	regServer = apptesting.NewServer(hf)

	hf = func(c *gin.Context) {
		Login(c)
		cu, ok = user.FromContext(c)
	}
	loginServer = apptesting.NewServer(hf)

	hf = func(c *gin.Context) {
		Logout(c)
		cu, ok = user.FromContext(c)
	}
	logoutServer = apptesting.NewServer(hf)

	hf = func(c *gin.Context) {
		Destroy(c)
		cu, ok = user.FromContext(c)
	}
	desServer = apptesting.NewServer(hf)

	os.Exit(m.Run())
}
Ejemplo n.º 3
0
func TestMain(m *testing.M) {
	hf := func(c *gin.Context) {
		session = FromContext(c)
	}
	server = apptesting.NewServer(hf)

	hf = func(c *gin.Context) {
		session = FromContext(c)
		session2 = FromContext(c)
	}
	dsServer = apptesting.NewServer(hf)
	models.DB.LogMode(false)
	os.Exit(m.Run())
}