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

Function TestUploadMissingFile

internal/attachments/client_test.go:356–370  ·  view source on GitHub ↗

A file can be removed between the validation that accepted it and the upload that opens it, which is the only way a resolved asset reaches the endpoint with nothing behind it.

(t *testing.T)

Source from the content-addressed store, hash-verified

354// that opens it, which is the only way a resolved asset reaches the endpoint
355// with nothing behind it.
356func TestUploadMissingFile(t *testing.T) {
357 a := testAsset(t, "gone.png", "image/png", "the bytes")
358 openFile = func(path string) (io.ReadCloser, error) {
359 return nil, &fs.PathError{Op: "open", Path: path, Err: fs.ErrNotExist}
360 }
361
362 reg := &httpmock.Registry{}
363 defer reg.Verify(t)
364
365 _, err := newTestUploader(t, reg, "github.com", 1).upload(context.Background(), a)
366
367 require.Error(t, err)
368 assert.Contains(t, err.Error(), "failed to upload ./gone.png: ")
369 assert.Empty(t, reg.Requests)
370}
371
372func TestNewUploader(t *testing.T) {
373 const badTokenErr = "unsupported authentication type"

Callers

nothing calls this directly

Calls 7

VerifyMethod · 0.95
testAssetFunction · 0.85
newTestUploaderFunction · 0.85
uploadMethod · 0.80
ContainsMethod · 0.80
EmptyMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected