MCPcopy
hub / github.com/basecamp/once / TestMetricsScraperScrapeServerError

Function TestMetricsScraperScrapeServerError

internal/metrics/scraper_test.go:283–296  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

281}
282
283func TestMetricsScraperScrapeServerError(t *testing.T) {
284 server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
285 http.Error(w, "internal error", http.StatusInternalServerError)
286 }))
287 defer server.Close()
288
289 scraper := NewMetricsScraper(ScraperSettings{
290 Port: serverPort(t, server),
291 BufferSize: 10,
292 })
293
294 scraper.Scrape(context.Background())
295 assert.Error(t, scraper.LastError())
296}
297
298func TestMetricsScraperScrapeServerUnavailable(t *testing.T) {
299 server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}))

Callers

nothing calls this directly

Calls 6

ScrapeMethod · 0.95
LastErrorMethod · 0.95
NewMetricsScraperFunction · 0.85
serverPortFunction · 0.85
ErrorMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…