Skip to content

Commit

Permalink
test: duplicate coco tests for cog commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tranzystorekk authored and oknozor committed Dec 14, 2021
1 parent 128b9d0 commit 3a3249c
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/bin/cog_commit.rs
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;
Expand Down
83 changes: 83 additions & 0 deletions tests/cog_tests/commit.rs
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(())
}
1 change: 1 addition & 0 deletions tests/cog_tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
mod bump;
mod changelog;
mod check;
mod commit;
mod init;
mod verify;

0 comments on commit 3a3249c

Please sign in to comment.