package test

import (
	"net/http"
	"net/http/httptest"

	"github.com/gin-gonic/gin"
	"github.com/pingcap/enterprise-toolkit/tispector/config"
	"github.com/pingcap/enterprise-toolkit/tispector/util/logger"

	"github.com/pingcap/enterprise-toolkit/tispector/router"
)

var token string = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImZpc2giLCJwYXNzd29yZCI6ImZseSJ9.8Lur8qWsME-nI_TdFS7aGqAUa4sbup8Qf2Lb5Oikx1g"

const (
	userName = "fish"
	pwd      = "fly"
)

func init() {
	logger.InitLog("../../config/", "log.txt", "debug")
	config.InitConfig("../../config/config.yml")
}

func serverRouter(req *http.Request) *httptest.ResponseRecorder {
	gin.SetMode(gin.TestMode)
	router := router.Router()
	respWriter := httptest.NewRecorder()
	router.ServeHTTP(respWriter, req)
	return respWriter
}
