GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — chore: use http.Status* instead of hard code (#1482) · NodejsMAS/gin@f45c928

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • auth_test.go
  • benchmarks_test.go
  • context_test.go
  • examples
    • basic
      • main.go
      • main_test.go
    • favicon
      • main.go
    • http2
      • main.go
    • realtime-advanced
      • routes.go
    • realtime-chat
      • main.go
  • githubapi_test.go
  • logger.go
  • logger_test.go
  • middleware_test.go
  • recovery_test.go
  • render
    • redirect.go
    • render_test.go
  • response_writer_test.go
  • routergroup_test.go
  • routes_test.go
  • utils_test.go
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎auth_test.go‎

Copy file name to clipboardExpand all lines: auth_test.go
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,15 @@ func TestBasicAuthSucceed(t *testing.T) {
9393
router := New()
9494
router.Use(BasicAuth(accounts))
9595
router.GET("/login", func(c *Context) {
96-
c.String(200, c.MustGet(AuthUserKey).(string))
96+
c.String(http.StatusOK, c.MustGet(AuthUserKey).(string))
9797
})
9898

9999
w := httptest.NewRecorder()
100100
req, _ := http.NewRequest("GET", "/login", nil)
101101
req.Header.Set("Authorization", authorizationHeader("admin", "password"))
102102
router.ServeHTTP(w, req)
103103

104-
assert.Equal(t, 200, w.Code)
104+
assert.Equal(t, http.StatusOK, w.Code)
105105
assert.Equal(t, "admin", w.Body.String())
106106
}
107107

@@ -112,7 +112,7 @@ func TestBasicAuth401(t *testing.T) {
112112
router.Use(BasicAuth(accounts))
113113
router.GET("/login", func(c *Context) {
114114
called = true
115-
c.String(200, c.MustGet(AuthUserKey).(string))
115+
c.String(http.StatusOK, c.MustGet(AuthUserKey).(string))
116116
})
117117

118118
w := httptest.NewRecorder()
@@ -121,7 +121,7 @@ func TestBasicAuth401(t *testing.T) {
121121
router.ServeHTTP(w, req)
122122

123123
assert.False(t, called)
124-
assert.Equal(t, 401, w.Code)
124+
assert.Equal(t, http.StatusUnauthorized, w.Code)
125125
assert.Equal(t, "Basic realm=\"Authorization Required\"", w.HeaderMap.Get("WWW-Authenticate"))
126126
}
127127

@@ -132,7 +132,7 @@ func TestBasicAuth401WithCustomRealm(t *testing.T) {
132132
router.Use(BasicAuthForRealm(accounts, "My Custom \"Realm\""))
133133
router.GET("/login", func(c *Context) {
134134
called = true
135-
c.String(200, c.MustGet(AuthUserKey).(string))
135+
c.String(http.StatusOK, c.MustGet(AuthUserKey).(string))
136136
})
137137

138138
w := httptest.NewRecorder()
@@ -141,6 +141,6 @@ func TestBasicAuth401WithCustomRealm(t *testing.T) {
141141
router.ServeHTTP(w, req)
142142

143143
assert.False(t, called)
144-
assert.Equal(t, 401, w.Code)
144+
assert.Equal(t, http.StatusUnauthorized, w.Code)
145145
assert.Equal(t, "Basic realm=\"My Custom \\\"Realm\\\"\"", w.HeaderMap.Get("WWW-Authenticate"))
146146
}
Collapse file

‎benchmarks_test.go‎

Copy file name to clipboardExpand all lines: benchmarks_test.go
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func BenchmarkOneRouteJSON(B *testing.B) {
5454
Status string `json:"status"`
5555
}{"ok"}
5656
router.GET("/json", func(c *Context) {
57-
c.JSON(200, data)
57+
c.JSON(http.StatusOK, data)
5858
})
5959
runRequest(B, router, "GET", "/json")
6060
}
@@ -66,7 +66,7 @@ func BenchmarkOneRouteHTML(B *testing.B) {
6666
router.SetHTMLTemplate(t)
6767

6868
router.GET("/html", func(c *Context) {
69-
c.HTML(200, "index", "hola")
69+
c.HTML(http.StatusOK, "index", "hola")
7070
})
7171
runRequest(B, router, "GET", "/html")
7272
}
@@ -82,7 +82,7 @@ func BenchmarkOneRouteSet(B *testing.B) {
8282
func BenchmarkOneRouteString(B *testing.B) {
8383
router := New()
8484
router.GET("/text", func(c *Context) {
85-
c.String(200, "this is a plain text")
85+
c.String(http.StatusOK, "this is a plain text")
8686
})
8787
runRequest(B, router, "GET", "/text")
8888
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.