Skip to content

Commit e67d77d

Browse files
committed
[git-packetline] another green test
1 parent 91c2895 commit e67d77d

File tree

2 files changed

+25
-16
lines changed

2 files changed

+25
-16
lines changed

git-packetline/tests/blocking/read/sideband.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -103,19 +103,3 @@ fn read_pack_with_progress_extraction() -> crate::Result {
103103
);
104104
Ok(())
105105
}
106-
#[test]
107-
fn peek_past_an_actual_eof_is_an_error() -> crate::Result {
108-
let input = b"0009ERR e";
109-
let mut rd = git_packetline::StreamingPeekableIter::new(&input[..], &[]);
110-
let mut reader = rd.as_read();
111-
assert_eq!(reader.peek_data_line().expect("one line")??, b"ERR e");
112-
let mut buf = String::new();
113-
reader.read_line(&mut buf)?;
114-
115-
assert_eq!(
116-
reader.peek_data_line().expect("an err").expect_err("foo").kind(),
117-
std::io::ErrorKind::UnexpectedEof,
118-
"peeking past the end is not an error as the caller should make sure we dont try 'invalid' reads"
119-
);
120-
Ok(())
121-
}

git-packetline/tests/read/sideband.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,30 @@ use git_packetline::PacketLine;
44
#[cfg(feature = "blocking-io")]
55
use std::io::{BufRead, Read};
66

7+
#[maybe_async::test(feature = "blocking-io", async(feature = "async-io", async_std::test))]
8+
async fn peek_past_an_actual_eof_is_an_error() -> crate::Result {
9+
let input = b"0009ERR e";
10+
let mut rd = git_packetline::StreamingPeekableIter::new(&input[..], &[]);
11+
let mut reader = rd.as_read();
12+
let res = reader.peek_data_line().await;
13+
assert_eq!(res.expect("one line")??, b"ERR e");
14+
15+
let mut buf = String::new();
16+
reader.read_line(&mut buf).await?;
17+
assert_eq!(
18+
buf, "ERR e",
19+
"by default ERR lines won't propagate as failure but are merely text"
20+
);
21+
22+
let res = reader.peek_data_line().await;
23+
assert_eq!(
24+
res.expect("an err").expect_err("foo").kind(),
25+
std::io::ErrorKind::UnexpectedEof,
26+
"peeking past the end is not an error as the caller should make sure we dont try 'invalid' reads"
27+
);
28+
Ok(())
29+
}
30+
731
#[maybe_async::test(feature = "blocking-io", async(feature = "async-io", async_std::test))]
832
async fn peek_past_a_delimiter_is_no_error() -> crate::Result {
933
let input = b"0009hello0000";
@@ -14,6 +38,7 @@ async fn peek_past_a_delimiter_is_no_error() -> crate::Result {
1438

1539
let mut buf = String::new();
1640
reader.read_line(&mut buf).await?;
41+
assert_eq!(buf, "hello");
1742

1843
let res = reader.peek_data_line().await;
1944
assert!(

0 commit comments

Comments
 (0)