mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2025-01-08 19:06:38 +03:00
38 lines
1.1 KiB
Rust
38 lines
1.1 KiB
Rust
|
use anyhow::Result;
|
||
|
use gitbutler_branch_actions::list_branches;
|
||
|
use gitbutler_command_context::ProjectRepository;
|
||
|
|
||
|
#[test]
|
||
|
fn on_main_single_branch_no_vbranch() -> Result<()> {
|
||
|
let list = list_branches(&project_ctx("single-branch-no-vbranch")?, None)?;
|
||
|
assert_eq!(list.len(), 1);
|
||
|
|
||
|
let branch = &list[0];
|
||
|
assert_eq!(branch.name, "main", "short names are used");
|
||
|
assert_eq!(branch.remotes, &["origin"]);
|
||
|
assert_eq!(branch.virtual_branch, None);
|
||
|
assert_eq!(
|
||
|
branch.authors,
|
||
|
[],
|
||
|
"there is no local commit, so no authors are known"
|
||
|
);
|
||
|
Ok(())
|
||
|
}
|
||
|
|
||
|
#[test]
|
||
|
fn on_main_single_branch_no_vbranch_multiple_remotes() -> Result<()> {
|
||
|
let list = list_branches(&project_ctx("single-branch-no-vbranch-multi-remote")?, None)?;
|
||
|
assert_eq!(list.len(), 1);
|
||
|
|
||
|
let branch = &list[0];
|
||
|
assert_eq!(branch.name, "main");
|
||
|
assert_eq!(branch.remotes, &["other-origin", "origin"]);
|
||
|
assert_eq!(branch.virtual_branch, None);
|
||
|
assert_eq!(branch.authors, []);
|
||
|
Ok(())
|
||
|
}
|
||
|
|
||
|
fn project_ctx(name: &str) -> anyhow::Result<ProjectRepository> {
|
||
|
gitbutler_testsupport::read_only::fixture("for-listing.sh", name)
|
||
|
}
|