mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-11-28 04:47:42 +03:00
more session tests
This commit is contained in:
parent
ab803a12a1
commit
efaba6b342
@ -47,7 +47,15 @@ fn test_create_current() {
|
||||
current_session.as_ref().unwrap().meta.branch,
|
||||
"refs/heads/master"
|
||||
);
|
||||
assert!(current_session.as_ref().unwrap().meta.commit.len() > 0);
|
||||
assert_eq!(
|
||||
current_session.as_ref().unwrap().meta.commit,
|
||||
repo.head()
|
||||
.unwrap()
|
||||
.peel_to_commit()
|
||||
.unwrap()
|
||||
.id()
|
||||
.to_string(),
|
||||
);
|
||||
assert_eq!(current_session.as_ref().unwrap().activity.len(), 0);
|
||||
}
|
||||
|
||||
@ -84,6 +92,25 @@ fn test_flush() {
|
||||
assert!(current_session.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_persistent() {
|
||||
let (repo, project) = test_project().unwrap();
|
||||
let created_session = super::sessions::Session::from_head(&repo, &project);
|
||||
assert!(created_session.is_ok());
|
||||
let mut created_session = created_session.unwrap();
|
||||
|
||||
created_session.flush(&repo, &None, &project).unwrap();
|
||||
|
||||
let commid_oid = git2::Oid::from_str(&created_session.hash.as_ref().unwrap()).unwrap();
|
||||
let commit = repo.find_commit(commid_oid).unwrap();
|
||||
|
||||
let reconstructed = super::sessions::Session::from_commit(&repo, &commit);
|
||||
assert!(reconstructed.is_ok());
|
||||
let reconstructed = reconstructed.unwrap();
|
||||
|
||||
assert_eq!(reconstructed, created_session);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_list() {
|
||||
let (repo, project) = test_project().unwrap();
|
||||
|
Loading…
Reference in New Issue
Block a user