(t *testing.T)
| 148 | } |
| 149 | |
| 150 | func TestHandle206Response(t *testing.T) { |
| 151 | body := io.NopCloser(bytes.NewReader([]byte("--AAA\r\n\r\n23\r\n--AAA\r\n\r\n5\r\n--AAA--"))) |
| 152 | defer body.Close() |
| 153 | streams := make(chan io.ReadCloser) |
| 154 | errs := make(chan error) |
| 155 | chunks := []private.ImageSourceChunk{ |
| 156 | {Offset: 1, Length: 2}, |
| 157 | {Offset: 4, Length: 1}, |
| 158 | } |
| 159 | mediaType := "multipart/form-data" |
| 160 | params := map[string]string{ |
| 161 | "boundary": "AAA", |
| 162 | } |
| 163 | go handle206Response(streams, errs, body, chunks, mediaType, params) |
| 164 | |
| 165 | expected := []verifyGetBlobAtData{ |
| 166 | {[]byte("23"), nil}, |
| 167 | {[]byte("5"), nil}, |
| 168 | {[]byte(nil), nil}, |
| 169 | } |
| 170 | verifyGetBlobAtOutput(t, streams, errs, expected) |
| 171 | |
| 172 | body = io.NopCloser(bytes.NewReader([]byte("HELLO"))) |
| 173 | defer body.Close() |
| 174 | streams = make(chan io.ReadCloser) |
| 175 | errs = make(chan error) |
| 176 | chunks = []private.ImageSourceChunk{{Offset: 100, Length: 5}} |
| 177 | mediaType = "text/plain" |
| 178 | params = map[string]string{} |
| 179 | go handle206Response(streams, errs, body, chunks, mediaType, params) |
| 180 | |
| 181 | expected = []verifyGetBlobAtData{ |
| 182 | {[]byte("HELLO"), nil}, |
| 183 | {[]byte(nil), nil}, |
| 184 | } |
| 185 | verifyGetBlobAtOutput(t, streams, errs, expected) |
| 186 | } |
| 187 | |
| 188 | func TestParseMediaType(t *testing.T) { |
| 189 | mediaType, params, err := parseMediaType("multipart/byteranges; boundary=CloudFront:3F750DE0752BEDE3882F7DBE80010D31") |
nothing calls this directly
no test coverage detected
searching dependent graphs…