Skip to content

Commit

Permalink
test: swap c.Assert operands for better error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
jnsgruk committed Feb 13, 2024
1 parent 81ebfd9 commit f9f6c12
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pkg/server/route_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (s *RouteHandlerTestSuite) TestRouteHandlerSimpleRedirects(c *check.C) {
func (s *RouteHandlerTestSuite) TestRouteHandlerRedirectNotFound(c *check.C) {
body, code := requestRoute(*s.server, "/undefined")

c.Assert(http.StatusNotFound, check.Equals, code)
c.Assert(code, check.Equals, http.StatusNotFound)
c.Assert(strings.TrimSpace(body), check.Equals, `Not found`)
// Check metrics were incremented properly
c.Assert(readCounter(s.server.metrics.requestsTotal), check.Equals, float64(1))
Expand All @@ -85,7 +85,7 @@ func (s *RouteHandlerTestSuite) TestRouteHandlerRedirectNotFoundRich(c *check.C)

body, code := requestRoute(*s.server, "/undefined")

c.Assert(http.StatusNotFound, check.Equals, code)
c.Assert(code, check.Equals, http.StatusNotFound)
c.Assert(strings.TrimSpace(body), check.Equals, `<h1>404</h1>`)
// Check metrics were incremented properly
c.Assert(readCounter(s.server.metrics.requestsTotal), check.Equals, float64(1))
Expand All @@ -103,14 +103,14 @@ func (s *RouteHandlerTestSuite) TestFileServeOk(c *check.C) {

body, code := requestRoute(*s.server, "/")

c.Assert(http.StatusOK, check.Equals, code)
c.Assert(code, check.Equals, http.StatusOK)
c.Assert(strings.TrimSpace(body), check.Equals, `<h1>Gosherve</h1>`)
// Check metrics were incremented properly
c.Assert(readCounterVec(*s.server.metrics.responseStatus, "200"), check.Equals, float64(1))

body, code = requestRoute(*s.server, "/script.js")

c.Assert(http.StatusOK, check.Equals, code)
c.Assert(code, check.Equals, http.StatusOK)
c.Assert(strings.TrimSpace(body), check.Equals, `alert('script')`)
// Check metrics were incremented properly
c.Assert(readCounterVec(*s.server.metrics.responseStatus, "200"), check.Equals, float64(2))
Expand All @@ -128,7 +128,7 @@ func (s *RouteHandlerTestSuite) TestDirectoryServeOk(c *check.C) {

body, code := requestRoute(*s.server, "/testDir")

c.Assert(http.StatusOK, check.Equals, code)
c.Assert(code, check.Equals, http.StatusOK)
c.Assert(strings.TrimSpace(body), check.Equals, `<h1>Gosherve</h1>`)
// Check metrics were incremented properly
c.Assert(readCounterVec(*s.server.metrics.responseStatus, "200"), check.Equals, float64(1))
Expand All @@ -138,7 +138,7 @@ func (s *RouteHandlerTestSuite) TestDirectoryServeOk(c *check.C) {
func (s *RouteHandlerTestSuite) TestFileServeNotFound(c *check.C) {
body, code := requestRoute(*s.server, "/")

c.Assert(http.StatusNotFound, check.Equals, code)
c.Assert(code, check.Equals, http.StatusNotFound)
c.Assert(strings.TrimSpace(body), check.Equals, `Not found`)
// Check metrics were incremented properly
c.Assert(readCounterVec(*s.server.metrics.responseStatus, "404"), check.Equals, float64(1))
Expand Down

0 comments on commit f9f6c12

Please sign in to comment.