mirror of
https://github.com/avelino/awesome-go.git
synced 2024-11-07 16:33:40 +00:00
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.
This commit is contained in:
parent
f59afbd692
commit
4cb206f636
@ -160,17 +160,17 @@ func testRepoState(toRun bool, href string, client *http.Client, staleRepos *[]s
|
|||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
json.NewDecoder(resp.Body).Decode(&repoResp)
|
json.NewDecoder(resp.Body).Decode(&repoResp)
|
||||||
if resp.StatusCode == 301 {
|
if resp.StatusCode == http.StatusMovedPermanently {
|
||||||
*staleRepos = append(*staleRepos, href+movedPermanently)
|
*staleRepos = append(*staleRepos, href+movedPermanently)
|
||||||
log.Printf("%s returned 301", href)
|
log.Printf("%s returned %d", href, resp.StatusCode)
|
||||||
isRepoAdded = true
|
isRepoAdded = true
|
||||||
}
|
}
|
||||||
if resp.StatusCode == 302 && !isRepoAdded {
|
if resp.StatusCode == http.StatusFound && !isRepoAdded {
|
||||||
*staleRepos = append(*staleRepos, href+status302)
|
*staleRepos = append(*staleRepos, href+status302)
|
||||||
log.Printf("%s returned 302", href)
|
log.Printf("%s returned %d", href, resp.StatusCode)
|
||||||
isRepoAdded = true
|
isRepoAdded = true
|
||||||
}
|
}
|
||||||
if resp.StatusCode >= 400 && !isRepoAdded {
|
if resp.StatusCode >= http.StatusBadRequest && !isRepoAdded {
|
||||||
*staleRepos = append(*staleRepos, href+deadLinkMessage)
|
*staleRepos = append(*staleRepos, href+deadLinkMessage)
|
||||||
log.Printf("%s might not exist!", href)
|
log.Printf("%s might not exist!", href)
|
||||||
isRepoAdded = true
|
isRepoAdded = true
|
||||||
|
Loading…
Reference in New Issue
Block a user