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

Function TestRESTWithFullURL

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

Source from the content-addressed store, hash-verified

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