Make golint happier
This commit is contained in:
@@ -17,10 +17,10 @@ type AuthOptions struct {
|
||||
}
|
||||
|
||||
func getRequestUserId(c *m.ReqContext) int64 {
|
||||
userId := c.Session.Get(session.SESS_KEY_USERID)
|
||||
userID := c.Session.Get(session.SESS_KEY_USERID)
|
||||
|
||||
if userId != nil {
|
||||
return userId.(int64)
|
||||
if userID != nil {
|
||||
return userID.(int64)
|
||||
}
|
||||
|
||||
return 0
|
||||
|
||||
@@ -20,7 +20,7 @@ func getDashboardUrlBySlug(orgId int64, slug string) (string, error) {
|
||||
return m.GetDashboardUrl(query.Result.Uid, query.Result.Slug), nil
|
||||
}
|
||||
|
||||
func RedirectFromLegacyDashboardUrl() macaron.Handler {
|
||||
func RedirectFromLegacyDashboardURL() macaron.Handler {
|
||||
return func(c *m.ReqContext) {
|
||||
slug := c.Params("slug")
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
func TestMiddlewareDashboardRedirect(t *testing.T) {
|
||||
Convey("Given the dashboard redirect middleware", t, func() {
|
||||
bus.ClearBusHandlers()
|
||||
redirectFromLegacyDashboardUrl := RedirectFromLegacyDashboardUrl()
|
||||
redirectFromLegacyDashboardUrl := RedirectFromLegacyDashboardURL()
|
||||
redirectFromLegacyDashboardSoloUrl := RedirectFromLegacyDashboardSoloUrl()
|
||||
|
||||
fakeDash := m.NewDashboard("Child dash")
|
||||
@@ -34,9 +34,9 @@ func TestMiddlewareDashboardRedirect(t *testing.T) {
|
||||
|
||||
Convey("Should redirect to new dashboard url with a 301 Moved Permanently", func() {
|
||||
So(sc.resp.Code, ShouldEqual, 301)
|
||||
redirectUrl, _ := sc.resp.Result().Location()
|
||||
So(redirectUrl.Path, ShouldEqual, m.GetDashboardUrl(fakeDash.Uid, fakeDash.Slug))
|
||||
So(len(redirectUrl.Query()), ShouldEqual, 2)
|
||||
redirectURL, _ := sc.resp.Result().Location()
|
||||
So(redirectURL.Path, ShouldEqual, m.GetDashboardUrl(fakeDash.Uid, fakeDash.Slug))
|
||||
So(len(redirectURL.Query()), ShouldEqual, 2)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -47,11 +47,11 @@ func TestMiddlewareDashboardRedirect(t *testing.T) {
|
||||
|
||||
Convey("Should redirect to new dashboard url with a 301 Moved Permanently", func() {
|
||||
So(sc.resp.Code, ShouldEqual, 301)
|
||||
redirectUrl, _ := sc.resp.Result().Location()
|
||||
expectedUrl := m.GetDashboardUrl(fakeDash.Uid, fakeDash.Slug)
|
||||
expectedUrl = strings.Replace(expectedUrl, "/d/", "/d-solo/", 1)
|
||||
So(redirectUrl.Path, ShouldEqual, expectedUrl)
|
||||
So(len(redirectUrl.Query()), ShouldEqual, 2)
|
||||
redirectURL, _ := sc.resp.Result().Location()
|
||||
expectedURL := m.GetDashboardUrl(fakeDash.Uid, fakeDash.Slug)
|
||||
expectedURL = strings.Replace(expectedURL, "/d/", "/d-solo/", 1)
|
||||
So(redirectURL.Path, ShouldEqual, expectedURL)
|
||||
So(len(redirectURL.Query()), ShouldEqual, 2)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -14,10 +14,10 @@ import (
|
||||
|
||||
func TestRecoveryMiddleware(t *testing.T) {
|
||||
Convey("Given an api route that panics", t, func() {
|
||||
apiUrl := "/api/whatever"
|
||||
recoveryScenario("recovery middleware should return json", apiUrl, func(sc *scenarioContext) {
|
||||
apiURL := "/api/whatever"
|
||||
recoveryScenario("recovery middleware should return json", apiURL, func(sc *scenarioContext) {
|
||||
sc.handlerFunc = PanicHandler
|
||||
sc.fakeReq("GET", apiUrl).exec()
|
||||
sc.fakeReq("GET", apiURL).exec()
|
||||
sc.req.Header.Add("content-type", "application/json")
|
||||
|
||||
So(sc.resp.Code, ShouldEqual, 500)
|
||||
@@ -27,10 +27,10 @@ func TestRecoveryMiddleware(t *testing.T) {
|
||||
})
|
||||
|
||||
Convey("Given a non-api route that panics", t, func() {
|
||||
apiUrl := "/whatever"
|
||||
recoveryScenario("recovery middleware should return html", apiUrl, func(sc *scenarioContext) {
|
||||
apiURL := "/whatever"
|
||||
recoveryScenario("recovery middleware should return html", apiURL, func(sc *scenarioContext) {
|
||||
sc.handlerFunc = PanicHandler
|
||||
sc.fakeReq("GET", apiUrl).exec()
|
||||
sc.fakeReq("GET", apiURL).exec()
|
||||
|
||||
So(sc.resp.Code, ShouldEqual, 500)
|
||||
So(sc.resp.Header().Get("content-type"), ShouldEqual, "text/html; charset=UTF-8")
|
||||
|
||||
Reference in New Issue
Block a user