MCPcopy Create free account
hub / github.com/cli/cli / TestNewCachedDetector

Function TestNewCachedDetector

internal/featuredetection/feature_detection_test.go:823–838  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

821}
822
823func TestNewCachedDetector(t *testing.T) {
824 reg := &httpmock.Registry{}
825 defer reg.Verify(t)
826 var gotHeader string
827 reg.Register(
828 httpmock.WithHost(httpmock.REST("GET", "api/v3/meta"), "git.my.org"),
829 func(req *http.Request) (*http.Response, error) {
830 gotHeader = req.Header.Get("X-GH-CACHE-TTL")
831 return httpmock.JSONResponse(map[string]string{"installed_version": "3.23.0"})(req)
832 },
833 )
834
835 _, err := NewCachedDetector(&http.Client{Transport: reg}, "git.my.org", 24*time.Hour).AuthFeatures()
836 require.NoError(t, err)
837 assert.Equal(t, "24h0m0s", gotHeader)
838}
839
840func TestDetectorClient(t *testing.T) {
841 tests := []struct {

Callers

nothing calls this directly

Calls 9

VerifyMethod · 0.95
RegisterMethod · 0.95
WithHostFunction · 0.92
RESTFunction · 0.92
JSONResponseFunction · 0.92
NewCachedDetectorFunction · 0.85
EqualMethod · 0.80
GetMethod · 0.65
AuthFeaturesMethod · 0.65

Tested by

no test coverage detected