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
311311 }
312312
313313 #[test]
314−fn handshake_and_lsrefs_v2() -> crate::Result {
314+fn handshake_and_lsrefs_and_fetch_v2() -> crate::Result {
315315 let (mut server, mut c) = serve_and_connect(
316316 "v2/http-handshake.response",
317317 "path/not/important/due/to/mock",
@@ -407,5 +407,50 @@ Accept: application/x-git-upload-pack-result · 89 unmodified lines
407407 .collect::<Vec<_>>()
408408 );
409409
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
439+Host: 127.0.0.1:{}
440+Transfer-Encoding: chunked
441+Content-Type: application/x-git-upload-pack-request
442+Accept: application/x-git-upload-pack-result
443+
444+16
445+0012command=fetch
446+0000
447+0
448+
449+",
450+ server.addr.port(),
451+ )
452+ .lines()
453+ .collect::<Vec<_>>()
454+ );
410455 Ok(())
411456 }
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
2424 * [x] send values + receive data with sidebands
2525 * [x] V2 handshake
2626 * [x] send command request
27− * [ ] http://git-upload-pack
27+ * [x] http://git-upload-pack
2828 * [x] V1 handshake
2929 * [x] send values + receive data with sidebands
3030 * [x] V2 handshake
31− * [ ] send command request
31+ * [x] send command request
3232 * [ ] connect
3333 * [ ] file
3434 * [ ] ssh