From 4cb206f636b013247ad35b1711ba65bbd5583341 Mon Sep 17 00:00:00 2001 From: jidicula Date: Wed, 26 Oct 2022 20:14:59 -0400 Subject: [PATCH] refactor(tests): Use net/http constants for status codes It's best to use the built-in library constants for status codes when possible as it improves readability, rather than having to look up status code definitions when otherwise changing behaviour. --- stale_repositories_test.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/stale_repositories_test.go b/stale_repositories_test.go index 8a992e4c..dc37bffd 100644 --- a/stale_repositories_test.go +++ b/stale_repositories_test.go @@ -160,17 +160,17 @@ func testRepoState(toRun bool, href string, client *http.Client, staleRepos *[]s } defer resp.Body.Close() json.NewDecoder(resp.Body).Decode(&repoResp) - if resp.StatusCode == 301 { + if resp.StatusCode == http.StatusMovedPermanently { *staleRepos = append(*staleRepos, href+movedPermanently) - log.Printf("%s returned 301", href) + log.Printf("%s returned %d", href, resp.StatusCode) isRepoAdded = true } - if resp.StatusCode == 302 && !isRepoAdded { + if resp.StatusCode == http.StatusFound && !isRepoAdded { *staleRepos = append(*staleRepos, href+status302) - log.Printf("%s returned 302", href) + log.Printf("%s returned %d", href, resp.StatusCode) isRepoAdded = true } - if resp.StatusCode >= 400 && !isRepoAdded { + if resp.StatusCode >= http.StatusBadRequest && !isRepoAdded { *staleRepos = append(*staleRepos, href+deadLinkMessage) log.Printf("%s might not exist!", href) isRepoAdded = true