Harden health checks and refresh GitHub health cache

This commit is contained in:
Julien Bisconti
2026-02-28 00:46:59 +01:00
parent 67cc5caaa5
commit ca2246667c
4 changed files with 2186 additions and 7 deletions

View File

@@ -1,6 +1,7 @@
package checker
import (
"errors"
"testing"
)
@@ -14,6 +15,10 @@ func TestExtractGitHubRepo(t *testing.T) {
{"https://github.com/docker/compose", "docker", "compose", true},
{"https://github.com/moby/moby", "moby", "moby", true},
{"https://github.com/user/repo/", "user", "repo", true},
{"https://github.com/user/repo?tab=readme-ov-file", "user", "repo", true},
{"https://github.com/user/repo#readme", "user", "repo", true},
{"https://github.com/user/repo.git", "user", "repo", true},
{"https://www.github.com/user/repo", "user", "repo", true},
{"https://github.com/user/repo/issues", "", "", false},
{"https://github.com/user/repo/wiki", "", "", false},
{"https://github.com/apps/dependabot", "", "", false},
@@ -52,3 +57,22 @@ func TestPartitionLinks(t *testing.T) {
t.Errorf("external links = %d, want 2", len(ext))
}
}
func TestIsGitHubAuthError(t *testing.T) {
tests := []struct {
err error
want bool
}{
{errors.New("non-200 OK status code: 401 Unauthorized body: \"Bad credentials\""), true},
{errors.New("Resource not accessible by integration"), true},
{errors.New("dial tcp: lookup api.github.com: no such host"), false},
{errors.New("context deadline exceeded"), false},
}
for _, tt := range tests {
got := isGitHubAuthError(tt.err)
if got != tt.want {
t.Errorf("isGitHubAuthError(%q) = %v, want %v", tt.err, got, tt.want)
}
}
}