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

Function StubUploadToHost

internal/attachments/test.go:54–59  ·  view source on GitHub ↗

StubUploadToHost is StubUpload plus the host the request reached. The matchers compare the path only, so the host is asserted in the responder or not at all.

(t *testing.T, reg *httpmock.Registry, host string, repositoryID int64, name string, status int, body string)

Source from the content-addressed store, hash-verified

52// matchers compare the path only, so the host is asserted in the responder or
53// not at all.
54func StubUploadToHost(t *testing.T, reg *httpmock.Registry, host string, repositoryID int64, name string, status int, body string) {
55 reg.Register(uploadMatcher(repositoryID, name), func(req *http.Request) (*http.Response, error) {
56 assert.Equal(t, host, req.URL.Host)
57 return httpmock.StatusStringResponse(status, body)(req)
58 })
59}
60
61func uploadMatcher(repositoryID int64, name string) httpmock.Matcher {
62 return httpmock.QueryMatcher("POST", "user-attachments/assets", url.Values{

Callers 4

Test_createRunFunction · 0.92
Test_editRunFunction · 0.92
Test_createRunFunction · 0.92
Test_editRunFunction · 0.92

Calls 4

StatusStringResponseFunction · 0.92
uploadMatcherFunction · 0.85
EqualMethod · 0.80
RegisterMethod · 0.45

Tested by 4

Test_createRunFunction · 0.74
Test_editRunFunction · 0.74
Test_createRunFunction · 0.74
Test_editRunFunction · 0.74