diff --git a/tests/lib_tests/log.rs b/tests/lib_tests/log.rs index 549386a4..b92175f6 100644 --- a/tests/lib_tests/log.rs +++ b/tests/lib_tests/log.rs @@ -4,6 +4,7 @@ use cocogitto::CocoGitto; use crate::helpers::*; use anyhow::Result; +use cmd_lib::run_cmd; use sealed_test::prelude::*; use speculoos::prelude::*; @@ -48,3 +49,31 @@ fn get_log_with_no_errors() -> Result<()> { Ok(()) } + +#[sealed_test] +fn get_log_on_master_only() -> Result<()> { + // Arrange + git_init()?; + let settings = r#"only_first_parent = true"#; + run_cmd!(echo $settings > cog.toml;)?; + git_commit("chore: initial commit")?; + + run_cmd!(git checkout -b feature)?; + git_commit("feat: a commit on feature branch")?; + git_commit("fix: a commit on feature branch")?; + run_cmd!( + git checkout master; + git merge --no-ff -m "feat: feature" feature; + )?; + + let filters = CommitFilters(vec![CommitFilter::NoError]); + let cocogitto = CocoGitto::get()?; + + // Act + let logs = cocogitto.get_log(filters)?; + + // Assert we don't see feature branch commit + assert_that!(logs).does_not_contain("a commit on feature branch"); + + Ok(()) +}