testUploadFile uploads a file and checks if it can be retrieved.
(t *testing.T, c *client.Client, f *fakeFile, withFileOpts bool)
| 66 | |
| 67 | // testUploadFile uploads a file and checks if it can be retrieved. |
| 68 | func 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 | } |
no test coverage detected