MCPcopy
hub / github.com/cli/cli / TestRESTWithFullURL

Function TestRESTWithFullURL

api/client_test.go:92–110  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

90}
91
92func TestRESTWithFullURL(t *testing.T) {
93 http := &httpmock.Registry{}
94 client := newTestClient(http)
95
96 http.Register(
97 httpmock.REST("GET", "api/v3/user/repos"),
98 httpmock.StatusStringResponse(200, "{}"))
99 http.Register(
100 httpmock.REST("GET", "user/repos"),
101 httpmock.StatusStringResponse(200, "{}"))
102
103 err := client.REST("example.com", "GET", "user/repos", nil, nil)
104 assert.NoError(t, err)
105 err = client.REST("example.com", "GET", "https://another.net/user/repos", nil, nil)
106 assert.NoError(t, err)
107
108 assert.Equal(t, "example.com", http.Requests[0].URL.Hostname())
109 assert.Equal(t, "another.net", http.Requests[1].URL.Hostname())
110}
111
112func TestRESTError(t *testing.T) {
113 fakehttp := &httpmock.Registry{}

Callers

nothing calls this directly

Calls 6

RegisterMethod · 0.95
RESTFunction · 0.92
StatusStringResponseFunction · 0.92
newTestClientFunction · 0.85
EqualMethod · 0.80
RESTMethod · 0.65

Tested by

no test coverage detected