style(format): reformat code with consistent line breaks and spacing
This commit is contained in:
+133
-106
@@ -522,208 +522,233 @@ async fn test_oid_binary_encoding() {
|
||||
assert_eq!(hex_from_bytes, oid.hex);
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn test_count_commits_head() {
|
||||
let (_dir, gb) = common::setup_bare_repo();
|
||||
let resp = gb.count_commits(CountCommitsRequest {
|
||||
repository: Some(hdr()),
|
||||
revision: String::new(),
|
||||
path: String::new(),
|
||||
since: String::new(),
|
||||
until: String::new(),
|
||||
}).unwrap();
|
||||
let resp = gb
|
||||
.count_commits(CountCommitsRequest {
|
||||
repository: Some(hdr()),
|
||||
revision: String::new(),
|
||||
path: String::new(),
|
||||
since: String::new(),
|
||||
until: String::new(),
|
||||
})
|
||||
.unwrap();
|
||||
assert_eq!(resp.count, 4);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_count_commits_with_revision() {
|
||||
let (_dir, gb) = common::setup_bare_repo();
|
||||
let resp = gb.count_commits(CountCommitsRequest {
|
||||
repository: Some(hdr()),
|
||||
revision: "feature".into(),
|
||||
path: String::new(),
|
||||
since: String::new(),
|
||||
until: String::new(),
|
||||
}).unwrap();
|
||||
let resp = gb
|
||||
.count_commits(CountCommitsRequest {
|
||||
repository: Some(hdr()),
|
||||
revision: "feature".into(),
|
||||
path: String::new(),
|
||||
since: String::new(),
|
||||
until: String::new(),
|
||||
})
|
||||
.unwrap();
|
||||
assert_eq!(resp.count, 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_count_commits_with_path() {
|
||||
let (_dir, gb) = common::setup_bare_repo();
|
||||
let resp = gb.count_commits(CountCommitsRequest {
|
||||
repository: Some(hdr()),
|
||||
revision: "main".into(),
|
||||
path: "README.md".into(),
|
||||
since: String::new(),
|
||||
until: String::new(),
|
||||
}).unwrap();
|
||||
let resp = gb
|
||||
.count_commits(CountCommitsRequest {
|
||||
repository: Some(hdr()),
|
||||
revision: "main".into(),
|
||||
path: "README.md".into(),
|
||||
since: String::new(),
|
||||
until: String::new(),
|
||||
})
|
||||
.unwrap();
|
||||
assert!(resp.count >= 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_count_diverging_commits() {
|
||||
let (_dir, gb) = common::setup_bare_repo();
|
||||
let resp = gb.count_diverging_commits(CountDivergingCommitsRequest {
|
||||
repository: Some(hdr()),
|
||||
left: "feature".into(),
|
||||
right: "main".into(),
|
||||
}).unwrap();
|
||||
let resp = gb
|
||||
.count_diverging_commits(CountDivergingCommitsRequest {
|
||||
repository: Some(hdr()),
|
||||
left: "feature".into(),
|
||||
right: "main".into(),
|
||||
})
|
||||
.unwrap();
|
||||
assert_eq!(resp.left_count, 0);
|
||||
assert_eq!(resp.right_count, 3);
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn test_find_commit_by_oid() {
|
||||
let (_dir, gb) = common::setup_bare_repo();
|
||||
let oid = common::get_main_oid(&gb);
|
||||
let commit = gb.find_commit(FindCommitRequest {
|
||||
repository: Some(hdr()),
|
||||
revision: common::oid_selector(&oid),
|
||||
include_stats: false,
|
||||
}).unwrap();
|
||||
let commit = gb
|
||||
.find_commit(FindCommitRequest {
|
||||
repository: Some(hdr()),
|
||||
revision: common::oid_selector(&oid),
|
||||
include_stats: false,
|
||||
})
|
||||
.unwrap();
|
||||
assert!(!commit.oid.as_ref().unwrap().hex.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_find_commit_by_revision() {
|
||||
let (_dir, gb) = common::setup_bare_repo();
|
||||
let commit = gb.find_commit(FindCommitRequest {
|
||||
repository: Some(hdr()),
|
||||
revision: common::rev_selector("main"),
|
||||
include_stats: false,
|
||||
}).unwrap();
|
||||
let commit = gb
|
||||
.find_commit(FindCommitRequest {
|
||||
repository: Some(hdr()),
|
||||
revision: common::rev_selector("main"),
|
||||
include_stats: false,
|
||||
})
|
||||
.unwrap();
|
||||
assert!(!commit.oid.as_ref().unwrap().hex.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_find_commit_default_head() {
|
||||
let (_dir, gb) = common::setup_bare_repo();
|
||||
let commit = gb.find_commit(FindCommitRequest {
|
||||
repository: Some(hdr()),
|
||||
revision: None,
|
||||
include_stats: false,
|
||||
}).unwrap();
|
||||
let commit = gb
|
||||
.find_commit(FindCommitRequest {
|
||||
repository: Some(hdr()),
|
||||
revision: None,
|
||||
include_stats: false,
|
||||
})
|
||||
.unwrap();
|
||||
assert!(!commit.oid.as_ref().unwrap().hex.is_empty());
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn test_list_commits_by_oid() {
|
||||
let (_dir, gb) = common::setup_bare_repo();
|
||||
let oid = common::get_main_oid(&gb);
|
||||
let oid_bytes = gitks::oid::hex_to_bytes(&oid).unwrap();
|
||||
let resp = gb.list_commits_by_oid(ListCommitsByOidRequest {
|
||||
repository: Some(hdr()),
|
||||
oids: vec![oid_bytes],
|
||||
include_stats: false,
|
||||
}).unwrap();
|
||||
let resp = gb
|
||||
.list_commits_by_oid(ListCommitsByOidRequest {
|
||||
repository: Some(hdr()),
|
||||
oids: vec![oid_bytes],
|
||||
include_stats: false,
|
||||
})
|
||||
.unwrap();
|
||||
assert_eq!(resp.commits.len(), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_list_commits_by_oid_empty() {
|
||||
let (_dir, gb) = common::setup_bare_repo();
|
||||
let resp = gb.list_commits_by_oid(ListCommitsByOidRequest {
|
||||
repository: Some(hdr()),
|
||||
oids: vec![],
|
||||
include_stats: false,
|
||||
}).unwrap();
|
||||
let resp = gb
|
||||
.list_commits_by_oid(ListCommitsByOidRequest {
|
||||
repository: Some(hdr()),
|
||||
oids: vec![],
|
||||
include_stats: false,
|
||||
})
|
||||
.unwrap();
|
||||
assert!(resp.commits.is_empty());
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn test_commits_by_message_basic() {
|
||||
let (_dir, gb) = common::setup_bare_repo();
|
||||
let resp = gb.commits_by_message(CommitsByMessageRequest {
|
||||
repository: Some(hdr()),
|
||||
query: "initial".into(),
|
||||
revision: String::new(),
|
||||
limit: 10,
|
||||
offset: 0,
|
||||
case_insensitive: false,
|
||||
}).unwrap();
|
||||
let resp = gb
|
||||
.commits_by_message(CommitsByMessageRequest {
|
||||
repository: Some(hdr()),
|
||||
query: "initial".into(),
|
||||
revision: String::new(),
|
||||
limit: 10,
|
||||
offset: 0,
|
||||
case_insensitive: false,
|
||||
})
|
||||
.unwrap();
|
||||
assert_eq!(resp.commits.len(), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_commits_by_message_case_insensitive() {
|
||||
let (_dir, gb) = common::setup_bare_repo();
|
||||
let resp = gb.commits_by_message(CommitsByMessageRequest {
|
||||
repository: Some(hdr()),
|
||||
query: "INITIAL".into(),
|
||||
revision: String::new(),
|
||||
limit: 10,
|
||||
offset: 0,
|
||||
case_insensitive: true,
|
||||
}).unwrap();
|
||||
let resp = gb
|
||||
.commits_by_message(CommitsByMessageRequest {
|
||||
repository: Some(hdr()),
|
||||
query: "INITIAL".into(),
|
||||
revision: String::new(),
|
||||
limit: 10,
|
||||
offset: 0,
|
||||
case_insensitive: true,
|
||||
})
|
||||
.unwrap();
|
||||
assert_eq!(resp.commits.len(), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_commits_by_message_no_match() {
|
||||
let (_dir, gb) = common::setup_bare_repo();
|
||||
let resp = gb.commits_by_message(CommitsByMessageRequest {
|
||||
repository: Some(hdr()),
|
||||
query: "zzzznonexistent".into(),
|
||||
revision: String::new(),
|
||||
limit: 10,
|
||||
offset: 0,
|
||||
case_insensitive: false,
|
||||
}).unwrap();
|
||||
let resp = gb
|
||||
.commits_by_message(CommitsByMessageRequest {
|
||||
repository: Some(hdr()),
|
||||
query: "zzzznonexistent".into(),
|
||||
revision: String::new(),
|
||||
limit: 10,
|
||||
offset: 0,
|
||||
case_insensitive: false,
|
||||
})
|
||||
.unwrap();
|
||||
assert!(resp.commits.is_empty());
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn test_check_objects_exist() {
|
||||
let (_dir, gb) = common::setup_bare_repo();
|
||||
let oid = common::get_main_oid(&gb);
|
||||
let resp = gb.check_objects_exist(CheckObjectsExistRequest {
|
||||
repository: Some(hdr()),
|
||||
revisions: vec![oid.clone(), "HEAD".into(), "nonexistent-branch".into()],
|
||||
}).unwrap();
|
||||
let resp = gb
|
||||
.check_objects_exist(CheckObjectsExistRequest {
|
||||
repository: Some(hdr()),
|
||||
revisions: vec![oid.clone(), "HEAD".into(), "nonexistent-branch".into()],
|
||||
})
|
||||
.unwrap();
|
||||
assert_eq!(resp.revisions.len(), 3);
|
||||
assert!(resp.revisions[0].exists);
|
||||
assert!(resp.revisions[1].exists);
|
||||
assert!(!resp.revisions[2].exists);
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn test_get_commit_stats() {
|
||||
let (_dir, gb) = common::setup_bare_repo();
|
||||
let oid = common::get_main_oid(&gb);
|
||||
let stats = gb.get_commit_stats(GetCommitStatsRequest {
|
||||
repository: Some(hdr()),
|
||||
revision: common::oid_selector(&oid),
|
||||
}).unwrap();
|
||||
let stats = gb
|
||||
.get_commit_stats(GetCommitStatsRequest {
|
||||
repository: Some(hdr()),
|
||||
revision: common::oid_selector(&oid),
|
||||
})
|
||||
.unwrap();
|
||||
assert!(stats.changed_files >= 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_commit_stats_default() {
|
||||
let (_dir, gb) = common::setup_bare_repo();
|
||||
let stats = gb.get_commit_stats(GetCommitStatsRequest {
|
||||
repository: Some(hdr()),
|
||||
revision: None,
|
||||
}).unwrap();
|
||||
let stats = gb
|
||||
.get_commit_stats(GetCommitStatsRequest {
|
||||
repository: Some(hdr()),
|
||||
revision: None,
|
||||
})
|
||||
.unwrap();
|
||||
assert!(stats.changed_files >= 1);
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn test_last_commit_for_path() {
|
||||
let (_dir, gb) = common::setup_bare_repo();
|
||||
let resp = gb.last_commit_for_path(LastCommitForPathRequest {
|
||||
repository: Some(hdr()),
|
||||
path: "README.md".into(),
|
||||
revision: "main".into(),
|
||||
literal_pathspec: false,
|
||||
}).unwrap();
|
||||
let resp = gb
|
||||
.last_commit_for_path(LastCommitForPathRequest {
|
||||
repository: Some(hdr()),
|
||||
path: "README.md".into(),
|
||||
revision: "main".into(),
|
||||
literal_pathspec: false,
|
||||
})
|
||||
.unwrap();
|
||||
assert!(resp.commit.is_some());
|
||||
assert_eq!(resp.path, "README.md");
|
||||
}
|
||||
@@ -731,11 +756,13 @@ fn test_last_commit_for_path() {
|
||||
#[test]
|
||||
fn test_last_commit_for_path_nonexistent() {
|
||||
let (_dir, gb) = common::setup_bare_repo();
|
||||
let resp = gb.last_commit_for_path(LastCommitForPathRequest {
|
||||
repository: Some(hdr()),
|
||||
path: "nonexistent.txt".into(),
|
||||
revision: "main".into(),
|
||||
literal_pathspec: false,
|
||||
}).unwrap();
|
||||
let resp = gb
|
||||
.last_commit_for_path(LastCommitForPathRequest {
|
||||
repository: Some(hdr()),
|
||||
path: "nonexistent.txt".into(),
|
||||
revision: "main".into(),
|
||||
literal_pathspec: false,
|
||||
})
|
||||
.unwrap();
|
||||
assert!(resp.commit.is_none());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user