History

[clone] Http fetch test for V2

Sebastian Thiel committed 6 years ago

Commit 81618ae1 parent 3ef1e473 files · +47 −2Browse files

Unified · Split

3 files
  1. git-transport/tests/client/http.rs +46 −1
  2. git-transport/tests/fixtures/v2/http-fetch.response +0 −0
  3. tasks.md +2 −2
git-transport/tests/client/http.rs+46−1
@@ -311,7 +311,7 @@ Accept: application/x-git-upload-pack-result · 310 unmodified lines
311}311}
312 312
313#[test]313#[test]
314fn handshake_and_lsrefs_v2() -> crate::Result {314fn handshake_and_lsrefs_and_fetch_v2() -> crate::Result {
315 let (mut server, mut c) = serve_and_connect(315 let (mut server, mut c) = serve_and_connect(
316 "v2/http-handshake.response",316 "v2/http-handshake.response",
317 "path/not/important/due/to/mock",317 "path/not/important/due/to/mock",
@@ -407,5 +407,50 @@ Accept: application/x-git-upload-pack-result · 89 unmodified lines
407 .collect::<Vec<_>>()407 .collect::<Vec<_>>()
408 );408 );
409 409
410 server.next_read_and_respond_with(fixture_bytes("v2/http-fetch.response"));
411 let mut res = c.invoke("fetch", Vec::new(), None::<Vec<bstr::BString>>)?;
412 let mut line = String::new();
413 res.read_line(&mut line)?;
414 assert_eq!(line, "packfile\n");
415
416 let messages = Rc::new(RefCell::new(Vec::<String>::new()));
417 res.set_progress_handler(Some(Box::new({
418 let sb = messages.clone();
419 move |is_err, data| {
420 assert!(!is_err);
421 sb.deref()
422 .borrow_mut()
423 .push(std::str::from_utf8(data).expect("valid utf8").to_owned())
424 }
425 })));
426
427 let mut pack = Vec::new();
428 res.read_to_end(&mut pack)?;
429 assert_eq!(pack.len(), 876);
430
431 drop(res);
432 let messages = Rc::try_unwrap(messages).expect("no other handle").into_inner();
433 assert_eq!(messages.len(), 5);
434
435 assert_eq!(
436 server.received_as_string().lines().collect::<Vec<_>>(),
437 format!(
438 "POST /path/not/important/due/to/mock/git-upload-pack HTTP/1.1
439Host: 127.0.0.1:{}
440Transfer-Encoding: chunked
441Content-Type: application/x-git-upload-pack-request
442Accept: application/x-git-upload-pack-result
443
44416
4450012command=fetch
4460000
4470
448
449",
450 server.addr.port(),
451 )
452 .lines()
453 .collect::<Vec<_>>()
454 );
410 Ok(())455 Ok(())
411}456}
git-transport/tests/fixtures/v2/http-fetch.response+0−0

Binary file not shown.

tasks.md+2−2
@@ -24,11 +24,11 @@ · 23 unmodified lines
24 * [x] send values + receive data with sidebands24 * [x] send values + receive data with sidebands
25 * [x] V2 handshake25 * [x] V2 handshake
26 * [x] send command request26 * [x] send command request
27 * [ ] http://git-upload-pack27 * [x] http://git-upload-pack
28 * [x] V1 handshake28 * [x] V1 handshake
29 * [x] send values + receive data with sidebands29 * [x] send values + receive data with sidebands
30 * [x] V2 handshake30 * [x] V2 handshake
31 * [ ] send command request31 * [x] send command request
32 * [ ] connect32 * [ ] connect
33 * [ ] file33 * [ ] file
34 * [ ] ssh34 * [ ] ssh