summaryrefslogtreecommitdiff
path: root/server/common/src/tests.rs
diff options
context:
space:
mode:
Diffstat (limited to 'server/common/src/tests.rs')
-rw-r--r--server/common/src/tests.rs53
1 files changed, 53 insertions, 0 deletions
diff --git a/server/common/src/tests.rs b/server/common/src/tests.rs
index 09e780b..34cc315 100644
--- a/server/common/src/tests.rs
+++ b/server/common/src/tests.rs
@@ -205,6 +205,53 @@ async fn git_get_author_commiter(repo: &git::Repository) {
assert!(repo.get_author("<invalid>").await.is_err());
}
+async fn git_ls_tree(repo: &git::Repository) {
+ let t1 = repo
+ .ls_tree("d7c502b9c6b833060576a0c4da0287933d603011", false)
+ .await
+ .unwrap();
+ assert_eq!(
+ t1,
+ vec![
+ git::TreeEntry {
+ object_type: git::ObjectType::BLOB,
+ object_name: "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391".to_string(),
+ path: "empty".to_string(),
+ },
+ git::TreeEntry {
+ object_type: git::ObjectType::BLOB,
+ object_name: "d393216eb885c4b4ec91b691dd59a88c846d881d".to_string(),
+ path: "phrase".to_string(),
+ },
+ ]
+ );
+
+ let t2 = repo
+ .ls_tree("2cecdec660a30bf3964cee645d9cee03640ef8dc", false)
+ .await
+ .unwrap();
+ assert_eq!(
+ t2,
+ vec![
+ git::TreeEntry {
+ object_type: git::ObjectType::BLOB,
+ object_name: "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391".to_string(),
+ path: "empty".to_string(),
+ },
+ git::TreeEntry {
+ object_type: git::ObjectType::BLOB,
+ object_name: "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391".to_string(),
+ path: "foo".to_string(),
+ },
+ git::TreeEntry {
+ object_type: git::ObjectType::BLOB,
+ object_name: "d393216eb885c4b4ec91b691dd59a88c846d881d".to_string(),
+ path: "phrase".to_string(),
+ },
+ ]
+ );
+}
+
async fn git_fetch(bare: bool) -> git::Repository {
let path = testdir!().join("repo");
let remote_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("src/testdata/bare");
@@ -289,6 +336,12 @@ async fn test_git_bare_delete_branch() {
}
#[tokio::test]
+async fn test_git_ls_tree() {
+ let repo = BARE.get_or_init(|| git_setup(true)).await;
+ git_ls_tree(repo).await;
+}
+
+#[tokio::test]
async fn test_grit_parse_base() {
let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("src/testdata/grit/base.grd");
let grit = grit::parse_grit(path).await.unwrap();