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

Function TestUploadMissingFile

internal/attachments/client_test.go:352–366  ·  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

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