Skip to content

Commit ce38ede

Browse files
committed
Fix verbose parsing unit tests
1 parent 0c39373 commit ce38ede

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ unit-tests: ## run all unit tests
103103
cargo test --all --no-fail-fast
104104
cd git-features && cargo test && cargo test --features fast-sha1
105105
cd git-transport && cargo test && cargo test --features http-client-curl
106+
cd gitoxide-core && cargo test --lib
106107

107108
continuous-unit-tests: ## run all unit tests whenever something changes
108109
watchexec -w src $(MAKE) unit-tests

gitoxide-core/src/organize.rs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ mod parse {
2222
use bstr::{BStr, ByteSlice};
2323

2424
#[allow(unused)]
25-
fn verbose_remotes(input: &[u8]) -> anyhow::Result<Vec<(&BStr, git_url::Url)>> {
25+
fn remotes_from_git_remote_verbose(input: &[u8]) -> anyhow::Result<Vec<(&BStr, git_url::Url)>> {
2626
fn parse_line(line: &BStr) -> anyhow::Result<(&BStr, git_url::Url)> {
2727
let mut tokens = line.splitn(2, |b| *b == b'\t');
2828
Ok(match (tokens.next(), tokens.next(), tokens.next()) {
@@ -54,16 +54,38 @@ mod parse {
5454
#[cfg(test)]
5555
mod tests {
5656
use super::*;
57+
use bstr::ByteSlice;
58+
5759
static GITOXIDE_REMOTES: &[u8] = br#"commitgraph https://github.com/avoidscorn/gitoxide (fetch)
5860
commitgraph https://github.com/avoidscorn/gitoxide (push)
5961
origin https://github.com/Byron/gitoxide (fetch)
6062
origin https://github.com/Byron/gitoxide (push)
6163
rad rad://hynkuwzskprmswzeo4qdtku7grdrs4ffj3g9tjdxomgmjzhtzpqf81@hwd1yregyf1dudqwkx85x5ps3qsrqw3ihxpx3ieopq6ukuuq597p6m8161c.git (fetch)
6264
rad rad://hynkuwzskprmswzeo4qdtku7grdrs4ffj3g9tjdxomgmjzhtzpqf81@hwd1yregyf1dudqwkx85x5ps3qsrqw3ihxpx3ieopq6ukuuq597p6m8161c.git (push)
6365
"#;
66+
fn url(input: &str) -> git_url::Url {
67+
git_url::Url::from_bytes(input.as_bytes()).expect("valid url")
68+
}
69+
6470
#[test]
6571
fn valid_verbose_remotes() -> anyhow::Result<()> {
66-
assert_eq!(verbose_remotes(GITOXIDE_REMOTES)?, vec![]);
72+
assert_eq!(
73+
remotes_from_git_remote_verbose(GITOXIDE_REMOTES)?,
74+
vec![
75+
(b"commitgraph".as_bstr(), url("https://github.com/avoidscorn/gitoxide")),
76+
(b"commitgraph".as_bstr(), url("https://github.com/avoidscorn/gitoxide")),
77+
(b"origin".as_bstr(), url("https://github.com/Byron/gitoxide")),
78+
(b"origin".as_bstr(), url("https://github.com/Byron/gitoxide")),
79+
(
80+
b"rad".as_bstr(),
81+
url("rad://hynkuwzskprmswzeo4qdtku7grdrs4ffj3g9tjdxomgmjzhtzpqf81@hwd1yregyf1dudqwkx85x5ps3qsrqw3ihxpx3ieopq6ukuuq597p6m8161c.git")
82+
),
83+
(
84+
b"rad".as_bstr(),
85+
url("rad://hynkuwzskprmswzeo4qdtku7grdrs4ffj3g9tjdxomgmjzhtzpqf81@hwd1yregyf1dudqwkx85x5ps3qsrqw3ihxpx3ieopq6ukuuq597p6m8161c.git")
86+
)
87+
]
88+
);
6789
Ok(())
6890
}
6991
}

0 commit comments

Comments
 (0)