MCPcopy Create free account
hub / github.com/containers/image / TestHandle206Response

Function TestHandle206Response

docker/docker_image_src_test.go:150–186  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

148}
149
150func 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
188func TestParseMediaType(t *testing.T) {
189 mediaType, params, err := parseMediaType("multipart/byteranges; boundary=CloudFront:3F750DE0752BEDE3882F7DBE80010D31")

Callers

nothing calls this directly

Calls 3

handle206ResponseFunction · 0.85
verifyGetBlobAtOutputFunction · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…