Allows reuse of the same testpb.Payload object.
(p *testpb.Payload, t testpb.PayloadType, size int)
| 45 | |
| 46 | // Allows reuse of the same testpb.Payload object. |
| 47 | func setPayload(p *testpb.Payload, t testpb.PayloadType, size int) { |
| 48 | if size < 0 { |
| 49 | logger.Fatalf("Requested a response with invalid length %d", size) |
| 50 | } |
| 51 | body := make([]byte, size) |
| 52 | switch t { |
| 53 | case testpb.PayloadType_COMPRESSABLE: |
| 54 | default: |
| 55 | logger.Fatalf("Unsupported payload type: %d", t) |
| 56 | } |
| 57 | p.Type = t |
| 58 | p.Body = body |
| 59 | } |
| 60 | |
| 61 | // NewPayload creates a payload with the given type and size. |
| 62 | func NewPayload(t testpb.PayloadType, size int) *testpb.Payload { |
no test coverage detected