MCPcopy Create free account
hub / github.com/GoogleChrome/webstatus.dev / TestNewHTTPFetcher

Function TestNewHTTPFetcher

lib/httputils/fetcher_test.go:38–58  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

36}
37
38func TestNewHTTPFetcher(t *testing.T) {
39 // nolint:exhaustruct // WONTFIX - external struct.
40 client := &http.Client{}
41
42 t.Run("valid URL", func(t *testing.T) {
43 fetcher, err := NewHTTPFetcher("http://example.com", client)
44 if err != nil {
45 t.Fatalf("unexpected error: %v", err)
46 }
47 if fetcher == nil {
48 t.Fatal("fetcher should not be nil")
49 }
50 })
51
52 t.Run("invalid URL", func(t *testing.T) {
53 _, err := NewHTTPFetcher(":", client)
54 if err == nil {
55 t.Fatal("expected an error for invalid URL, but got nil")
56 }
57 })
58}
59
60func TestHTTPFetcher_Fetch(t *testing.T) {
61 t.Run("successful fetch", func(t *testing.T) {

Callers

nothing calls this directly

Calls 2

NewHTTPFetcherFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected