Skip to content

Commit

Permalink
Use consistent casing in test names
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinmcconnell committed Oct 6, 2024
1 parent cae6215 commit f5e61ad
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions internal/server/error_page_middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestErrorPageMiddleware(t *testing.T) {
return resp.Result().StatusCode, resp.Header().Get("Content-Type"), resp.Body.String()
}

t.Run("When setting a custom error response", func(t *testing.T) {
t.Run("when setting a custom error response", func(t *testing.T) {
status, contentType, body := check(func(w http.ResponseWriter, r *http.Request) {
SetErrorResponse(w, r, http.StatusNotFound, nil)
})
Expand All @@ -36,7 +36,7 @@ func TestErrorPageMiddleware(t *testing.T) {
assert.Regexp(t, "Not Found", body)
})

t.Run("When including template arguments in a custom error response", func(t *testing.T) {
t.Run("when including template arguments in a custom error response", func(t *testing.T) {
status, contentType, body := check(func(w http.ResponseWriter, r *http.Request) {
SetErrorResponse(w, r, http.StatusServiceUnavailable, struct{ Message string }{"Gone to lunch"})
})
Expand All @@ -47,7 +47,7 @@ func TestErrorPageMiddleware(t *testing.T) {
assert.Regexp(t, "Gone to lunch", body)
})

t.Run("When trying to set an error that we don't have a template for", func(t *testing.T) {
t.Run("when trying to set an error that we don't have a template for", func(t *testing.T) {
status, contentType, body := check(func(w http.ResponseWriter, r *http.Request) {
SetErrorResponse(w, r, http.StatusTeapot, nil)
})
Expand All @@ -57,7 +57,7 @@ func TestErrorPageMiddleware(t *testing.T) {
assert.Regexp(t, "I'm a teapot", body)
})

t.Run("When the backend returns an error normally", func(t *testing.T) {
t.Run("when the backend returns an error normally", func(t *testing.T) {
status, contentType, body := check(func(w http.ResponseWriter, r *http.Request) {
http.Error(w, http.StatusText(http.StatusTeapot), http.StatusTeapot)
})
Expand Down Expand Up @@ -85,7 +85,7 @@ func TestErrorPageMiddleware_Nesting(t *testing.T) {
return resp.Result().StatusCode, resp.Header().Get("Content-Type"), resp.Body.String()
}

t.Run("With an error in the inner FS", func(t *testing.T) {
t.Run("with an error in the inner FS", func(t *testing.T) {
status, contentType, body := check(func(w http.ResponseWriter, r *http.Request) {
SetErrorResponse(w, r, http.StatusNotFound, nil)
})
Expand All @@ -95,7 +95,7 @@ func TestErrorPageMiddleware_Nesting(t *testing.T) {
assert.Regexp(t, "Custom 404", body)
})

t.Run("With an error not in the inner FS", func(t *testing.T) {
t.Run("with an error not in the inner FS", func(t *testing.T) {
status, contentType, body := check(func(w http.ResponseWriter, r *http.Request) {
SetErrorResponse(w, r, http.StatusServiceUnavailable, struct{ Message string }{"Gone to lunch"})
})
Expand All @@ -106,7 +106,7 @@ func TestErrorPageMiddleware_Nesting(t *testing.T) {
assert.Regexp(t, "Gone to lunch", body)
})

t.Run("With an error not in any FS", func(t *testing.T) {
t.Run("with an error not in any FS", func(t *testing.T) {
status, contentType, body := check(func(w http.ResponseWriter, r *http.Request) {
SetErrorResponse(w, r, http.StatusTeapot, nil)
})
Expand All @@ -125,14 +125,14 @@ func TestErrorPageMiddleware_WithInvalidArguments(t *testing.T) {
assert.Equal(t, ErrorUnableToLoadErrorPages, err)
}

t.Run("With templates that cannot be compiled", func(t *testing.T) {
t.Run("with templates that cannot be compiled", func(t *testing.T) {
pages := fstest.MapFS(map[string]*fstest.MapFile{
"404.html": {Data: []byte("<body>{{ {{</body>")},
})
ensureFailed(pages)
})

t.Run("With a filesystem that has no templates", func(t *testing.T) {
t.Run("with a filesystem that has no templates", func(t *testing.T) {
pages := fstest.MapFS(map[string]*fstest.MapFile{})
ensureFailed(pages)
})
Expand Down
4 changes: 2 additions & 2 deletions internal/server/request_id_middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/stretchr/testify/assert"
)

func TestRequestIDMiddleware_adds_an_id_when_not_present(t *testing.T) {
func TestRequestIDMiddleware_AddsAnIDWhenNotPresent(t *testing.T) {
handler := WithRequestIDMiddleware(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
id := r.Header.Get("X-Request-ID")
assert.NotEmpty(t, id)
Expand All @@ -21,7 +21,7 @@ func TestRequestIDMiddleware_adds_an_id_when_not_present(t *testing.T) {
assert.Equal(t, http.StatusOK, w.Code)
}

func TestRequestIDMiddleware_preserves_existing_header_when_present(t *testing.T) {
func TestRequestIDMiddleware_PreservesExistingHeaderWhenPresent(t *testing.T) {
next := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
id := r.Header.Get("X-Request-ID")
assert.Equal(t, "1234", id)
Expand Down

0 comments on commit f5e61ad

Please sign in to comment.