Refactor TestHeadMetrics for improved testing

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Luan DangandCopilot Autofix powered by AI authored and André Roth committed 2026-11-03 11:42:38 +01:00
1 parent 328120f80a
commit 198c801f00
1 file changed
+13 -3
+13 -3
View File
@@ -160,10 +160,20 @@ func (s *APISuite) TestGetMetrics(c *C) {
}
func (s *APISuite) TestHeadMetrics(c *C) {
response, err := s.HTTPRequest("HEAD", "/api/metrics", nil)
server := httptest.NewServer(s.router)
defer server.Close()
req, err := http.NewRequest(http.MethodHead, server.URL+"/api/metrics", nil)
c.Assert(err, IsNil)
c.Check(response.Code, Equals, 200)
c.Check(strings.Contains(response.Body.String(), "# TYPE aptly_build_info gauge"), Equals, true)
resp, err := server.Client().Do(req)
c.Assert(err, IsNil)
defer resp.Body.Close()
c.Check(resp.StatusCode, Equals, 200)
body, readErr := io.ReadAll(resp.Body)
c.Assert(readErr, IsNil)
c.Check(len(body), Equals, 0)
}
func (s *APISuite) TestRepoCreate(c *C) {