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

Function StubUploadToHost

internal/attachments/test.go:74–79  ·  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

72// matchers compare the path only, so the host is asserted in the responder or
73// not at all.
74func StubUploadToHost(t *testing.T, reg *httpmock.Registry, host string, repositoryID int64, name string, status int, body string) {
75 reg.Register(uploadMatcher(repositoryID, name), func(req *http.Request) (*http.Response, error) {
76 assert.Equal(t, host, req.URL.Host)
77 return httpmock.StatusStringResponse(status, body)(req)
78 })
79}
80
81func uploadMatcher(repositoryID int64, name string) httpmock.Matcher {
82 return httpmock.QueryMatcher("POST", "user-attachments/assets", url.Values{

Callers 8

Test_createRunFunction · 0.92
TestNewUploaderFunction · 0.92
TestCreateRunFunction · 0.92
TestEditRunFunction · 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 8

Test_createRunFunction · 0.74
TestNewUploaderFunction · 0.74
TestCreateRunFunction · 0.74
TestEditRunFunction · 0.74
Test_editRunFunction · 0.74
Test_createRunFunction · 0.74
Test_editRunFunction · 0.74