Skip to content

Commit

Permalink
chore(tests): don't check last commit (#619)
Browse files Browse the repository at this point in the history
* chore(tests): don't check last commit

* clippy
  • Loading branch information
MarcoIeni authored Apr 21, 2024
1 parent 522bd53 commit 68b9839
Showing 1 changed file with 16 additions and 28 deletions.
44 changes: 16 additions & 28 deletions git-cliff-core/src/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ impl Repository {
mod test {
use super::*;
use crate::commit::Commit as AppCommit;
use git_conventional::ErrorKind;
use std::env;
use std::process::Command;
use std::str;
Expand Down Expand Up @@ -239,42 +238,36 @@ mod test {
.to_string())
}

#[test]
fn git_log() -> Result<()> {
let repository = Repository::init(
fn get_repository() -> Result<Repository> {
Repository::init(
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.parent()
.expect("parent directory not found")
.to_path_buf(),
)?;
)
}

#[test]
fn get_latest_commit() -> Result<()> {
let repository = get_repository()?;
let commits = repository.commits(None, None, None)?;
let last_commit =
AppCommit::from(&commits.first().expect("no commits found").clone());
assert_eq!(get_last_commit_hash()?, last_commit.id);
if let Err(e) = last_commit.into_conventional() {
match e {
Error::ParseError(e) => {
eprintln!("\nthe last commit is not conventional\n");
assert_eq!(ErrorKind::InvalidFormat, e.kind())
}
_ => {
unreachable!()
}
}
}
Ok(())
}

#[test]
fn get_latest_tag() -> Result<()> {
let repository = get_repository()?;
let tags = repository.tags(&None, false)?;
assert_eq!(&get_last_tag()?, tags.last().expect("no tags found").1);
Ok(())
}

#[test]
fn git_tags() -> Result<()> {
let repository = Repository::init(
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.parent()
.expect("parent directory not found")
.to_path_buf(),
)?;
let repository = get_repository()?;
let tags = repository.tags(&None, true)?;
assert_eq!(
tags.get("2b8b4d3535f29231e05c3572e919634b9af907b6").expect(
Expand Down Expand Up @@ -308,12 +301,7 @@ mod test {

#[test]
fn git_upstream_remote() -> Result<()> {
let repository = Repository::init(
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.parent()
.expect("parent directory not found")
.to_path_buf(),
)?;
let repository = get_repository()?;
let remote = repository.upstream_remote()?;
assert_eq!(
Remote {
Expand Down

0 comments on commit 68b9839

Please sign in to comment.