fetchOrErrorString fetches br from sto and returns its body as a string. If an error occurs the stringified error is returned, prefixed by "Error: ".
(br blob.Ref)
| 58 | // fetchOrErrorString fetches br from sto and returns its body as a string. |
| 59 | // If an error occurs the stringified error is returned, prefixed by "Error: ". |
| 60 | func (ts *testStorage) fetchOrErrorString(br blob.Ref) string { |
| 61 | rc, _, err := ts.sto.Fetch(ctxbg, br) |
| 62 | var slurp []byte |
| 63 | if err == nil { |
| 64 | defer rc.Close() |
| 65 | slurp, err = io.ReadAll(rc) |
| 66 | } |
| 67 | if err != nil { |
| 68 | return fmt.Sprintf("Error: %v", err) |
| 69 | } |
| 70 | return string(slurp) |
| 71 | } |
| 72 | |
| 73 | func newTestStorage() *testStorage { |
| 74 | sto := &storage{ |
no test coverage detected