From f9f6c122368d3c75f4c7019ea67542973ce9f0f5 Mon Sep 17 00:00:00 2001 From: Jon Seager Date: Tue, 13 Feb 2024 09:11:48 +0000 Subject: [PATCH] test: swap c.Assert operands for better error reporting --- pkg/server/route_handler_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/server/route_handler_test.go b/pkg/server/route_handler_test.go index 72f57a4..39e2bcc 100644 --- a/pkg/server/route_handler_test.go +++ b/pkg/server/route_handler_test.go @@ -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)) @@ -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, `

404

`) // Check metrics were incremented properly c.Assert(readCounter(s.server.metrics.requestsTotal), check.Equals, float64(1)) @@ -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, `

Gosherve

`) // 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)) @@ -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, `

Gosherve

`) // Check metrics were incremented properly c.Assert(readCounterVec(*s.server.metrics.responseStatus, "200"), check.Equals, float64(1)) @@ -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))