-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: duplicate coco tests for cog commit
- Loading branch information
1 parent
128b9d0
commit 3a3249c
Showing
3 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#![cfg(not(tarpaulin_include))] | ||
use std::fmt::Write; | ||
|
||
use cocogitto::COMMITS_METADATA; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
use std::process::Command; | ||
|
||
use crate::helpers::*; | ||
|
||
use anyhow::Result; | ||
use assert_cmd::prelude::*; | ||
use sealed_test::prelude::*; | ||
|
||
#[sealed_test] | ||
fn commit_ok() -> Result<()> { | ||
// Arrange | ||
git_init()?; | ||
git_add("content", "test_file")?; | ||
|
||
// Act | ||
Command::cargo_bin("cog")? | ||
.arg("commit") | ||
.arg("feat") | ||
.arg("this is a commit message") | ||
.arg("scope") | ||
// Assert | ||
.assert() | ||
.success(); | ||
Ok(()) | ||
} | ||
|
||
#[sealed_test] | ||
fn unstaged_changes_commit_err() -> Result<()> { | ||
// Arrange | ||
git_init()?; | ||
std::fs::write("test_file", "content")?; | ||
|
||
// Act | ||
Command::cargo_bin("cog")? | ||
.arg("commit") | ||
.arg("feat") | ||
.arg("this is a commit message") | ||
.arg("scope") | ||
.arg("this is the body") | ||
.arg("this is the footer") | ||
// Assert | ||
.assert() | ||
.failure(); | ||
Ok(()) | ||
} | ||
|
||
#[sealed_test] | ||
fn untracked_changes_commit_ok() -> Result<()> { | ||
// Arrange | ||
git_init()?; | ||
git_add("content", "staged")?; | ||
std::fs::write("untracked", "content")?; | ||
|
||
// Act | ||
Command::cargo_bin("cog")? | ||
.arg("commit") | ||
.arg("feat") | ||
.arg("this is a commit message") | ||
.arg("scope") | ||
// Assert | ||
.assert() | ||
.success(); | ||
Ok(()) | ||
} | ||
|
||
#[sealed_test] | ||
fn empty_commit_err() -> Result<()> { | ||
// Arrange | ||
git_init()?; | ||
|
||
// Act | ||
Command::cargo_bin("cog")? | ||
.arg("commit") | ||
.arg("feat") | ||
.arg("this is a commit message") | ||
.arg("scope") | ||
.arg("this is the body") | ||
.arg("this is the footer") | ||
// Assert | ||
.assert() | ||
.failure(); | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,6 @@ | |
mod bump; | ||
mod changelog; | ||
mod check; | ||
mod commit; | ||
mod init; | ||
mod verify; |