Unified · Split
| @@ -311,7 +311,7 @@ Accept: application/x-git-upload-pack-result · 310 unmodified lines | |||
| 311 | } | 311 | } |
| 312 | 312 | ||
| 313 | #[test] | 313 | #[test] |
| 314 | fn handshake_and_lsrefs_v2() -> crate::Result { | 314 | fn 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 | ||
| 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 | ); | ||
| 410 | Ok(()) | 455 | Ok(()) |
| 411 | } | 456 | } |
Binary file not shown.
| @@ -24,11 +24,11 @@ · 23 unmodified lines | |||
| 24 | * [x] send values + receive data with sidebands | 24 | * [x] send values + receive data with sidebands |
| 25 | * [x] V2 handshake | 25 | * [x] V2 handshake |
| 26 | * [x] send command request | 26 | * [x] send command request |
| 27 | * [ ] http://git-upload-pack | 27 | * [x] http://git-upload-pack |
| 28 | * [x] V1 handshake | 28 | * [x] V1 handshake |
| 29 | * [x] send values + receive data with sidebands | 29 | * [x] send values + receive data with sidebands |
| 30 | * [x] V2 handshake | 30 | * [x] V2 handshake |
| 31 | * [ ] send command request | 31 | * [x] send command request |
| 32 | * [ ] connect | 32 | * [ ] connect |
| 33 | * [ ] file | 33 | * [ ] file |
| 34 | * [ ] ssh | 34 | * [ ] ssh |