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

Function TestMetricsScraperScrapeServerUnavailable

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

Source from the content-addressed store, hash-verified

296}
297
298func TestMetricsScraperScrapeServerUnavailable(t *testing.T) {
299 server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}))
300 port := serverPort(t, server)
301 server.Close()
302
303 scraper := NewMetricsScraper(ScraperSettings{
304 Port: port,
305 BufferSize: 10,
306 })
307
308 scraper.Scrape(context.Background())
309 assert.Error(t, scraper.LastError())
310 assert.Contains(t, scraper.LastError().Error(), "fetching metrics")
311}
312
313func TestMetricsScraperScrapeErrorClears(t *testing.T) {
314 available := atomic.Bool{}

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…