Skip to content

Commit ae57cf3

Browse files
author
Stephan Dilly
committed
add unittest for inconclusive default remote (#492)
1 parent 2989df0 commit ae57cf3

File tree

1 file changed

+38
-0
lines changed
  • asyncgit/src/sync/remotes

1 file changed

+38
-0
lines changed

asyncgit/src/sync/remotes/mod.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,4 +186,42 @@ mod tests {
186186
.unwrap();
187187
assert_eq!(first, String::from("origin"));
188188
}
189+
190+
#[test]
191+
fn test_default_remote_inconclusive() {
192+
let td = TempDir::new().unwrap();
193+
194+
debug_cmd_print(
195+
td.path().as_os_str().to_str().unwrap(),
196+
"git clone https://github.com/extrawurst/brewdump.git",
197+
);
198+
199+
debug_cmd_print(
200+
td.path().as_os_str().to_str().unwrap(),
201+
"cd brewdump && git remote rename origin alternate",
202+
);
203+
204+
debug_cmd_print(
205+
td.path().as_os_str().to_str().unwrap(),
206+
"cd brewdump && git remote add someremote https://github.com/extrawurst/brewdump.git",
207+
);
208+
209+
let repo_path = td.path().join("brewdump");
210+
let repo_path = repo_path.as_os_str().to_str().unwrap();
211+
212+
let remotes = get_remotes(repo_path).unwrap();
213+
assert_eq!(
214+
remotes,
215+
vec![
216+
String::from("alternate"),
217+
String::from("someremote")
218+
]
219+
);
220+
221+
let res = get_default_remote_in_repo(
222+
&utils::repo(repo_path).unwrap(),
223+
);
224+
assert_eq!(res.is_err(), true);
225+
assert!(matches!(res, Err(Error::NoDefaultRemoteFound)));
226+
}
189227
}

0 commit comments

Comments
 (0)