MCPcopy
hub / github.com/perkeep/perkeep / testUploadFile

Function testUploadFile

pkg/test/integration/upload_test.go:68–88  ·  view source on GitHub ↗

testUploadFile uploads a file and checks if it can be retrieved.

(t *testing.T, c *client.Client, f *fakeFile, withFileOpts bool)

Source from the content-addressed store, hash-verified

66
67// testUploadFile uploads a file and checks if it can be retrieved.
68func testUploadFile(t *testing.T, c *client.Client, f *fakeFile, withFileOpts bool) *schema.Blob {
69 var (
70 ctxbg = context.Background()
71 opts *client.FileUploadOptions
72 )
73 if withFileOpts {
74 opts = &client.FileUploadOptions{FileInfo: f}
75 }
76 bref, err := c.UploadFile(ctxbg, f.Name(), strings.NewReader(f.content), opts)
77 if err != nil {
78 t.Fatal(err)
79 }
80 sb, err := c.FetchSchemaBlob(ctxbg, bref)
81 if err != nil {
82 t.Fatal(err)
83 }
84 if sb.Type() != "file" {
85 t.Fatal(`schema blob from UploadFile must have "file" type`)
86 }
87 return sb
88}

Callers 1

TestUploadFileFunction · 0.85

Calls 5

FatalMethod · 0.80
FetchSchemaBlobMethod · 0.80
NameMethod · 0.65
UploadFileMethod · 0.45
TypeMethod · 0.45

Tested by

no test coverage detected