mirror of
https://github.com/lukaszraczylo/ghtracker.git
synced 2026-10-17 01:17:48 +00:00
fix(collector): link a failed repository to the configured host
When the first scan of a repository failed, the repository link pointed at github.com. It now follows github.api_url: Enterprise Server hosts drop the /api/v3 suffix and Enterprise Cloud hosts drop the api. prefix.
This commit is contained in:
@@ -337,3 +337,17 @@ func TestScanProgressAdvancesAsReposFinish(t *testing.T) {
|
||||
t.Fatalf("after scan: done=%d total=%d", v.ScanDone, v.ScanTotal)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFailedFirstScanLinksToTheConfiguredHost(t *testing.T) {
|
||||
fail := &fakeFetcher{fn: func(string) (model.Repo, error) { return model.Repo{}, errors.New("nope") }}
|
||||
cfg := &config.Config{
|
||||
Repos: []string{"o/a"}, RefreshInterval: time.Hour, Concurrency: 1, Thresholds: th(),
|
||||
GitHub: config.GitHub{APIURL: "https://ghe.example.com/api/v3"},
|
||||
}
|
||||
c := New(fail, cfg, slog.New(slog.NewTextHandler(io.Discard, nil)))
|
||||
c.now = func() time.Time { return t0 }
|
||||
c.Refresh(context.Background())
|
||||
if got := c.View().Repos[0].URL; got != "https://ghe.example.com/o/a" {
|
||||
t.Fatalf("repo link = %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user