Add a failing test to show that master isn't supported
```git-check-assertions run ./test/git-check-assertions.bats assert_failure assert_output --partial "fatal: Not a valid object name main" ```
This commit is contained in:
parent
fcea18e820
commit
e495aa826e
1 changed files with 28 additions and 8 deletions
|
|
@ -1,5 +1,19 @@
|
||||||
#!/usr/bin/env bats
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
init_repo() {
|
||||||
|
local repo_dir="$1"
|
||||||
|
local main_branch="$2"
|
||||||
|
|
||||||
|
mkdir "$repo_dir"
|
||||||
|
cd "$repo_dir"
|
||||||
|
git init -b "$main_branch"
|
||||||
|
git config user.email "john.doe@example.com"
|
||||||
|
git config user.name "John Doe"
|
||||||
|
touch readme
|
||||||
|
git add readme
|
||||||
|
git commit -m "initial"
|
||||||
|
}
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
|
@ -10,14 +24,7 @@ setup() {
|
||||||
DIR="$(cd "$(dirname "$BATS_TEST_FILENAME")" >/dev/null 2>&1 && pwd)"
|
DIR="$(cd "$(dirname "$BATS_TEST_FILENAME")" >/dev/null 2>&1 && pwd)"
|
||||||
PATH="$DIR/../bin:$PATH"
|
PATH="$DIR/../bin:$PATH"
|
||||||
|
|
||||||
mkdir "$BATS_TEST_TMPDIR/repo"
|
init_repo "$BATS_TEST_TMPDIR/repo" main
|
||||||
cd "$BATS_TEST_TMPDIR/repo"
|
|
||||||
git init -b main
|
|
||||||
git config user.email "john.doe@example.com"
|
|
||||||
git config user.name "John Doe"
|
|
||||||
touch readme
|
|
||||||
git add readme
|
|
||||||
git commit -m "initial"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
commit_with_assertion() {
|
commit_with_assertion() {
|
||||||
|
|
@ -50,6 +57,19 @@ commit_with_assertion() {
|
||||||
assert_file_not_exists ../test
|
assert_file_not_exists ../test
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "should not run any assertion blocks from master when on a feature branch" {
|
||||||
|
init_repo "$BATS_TEST_TMPDIR/repo-master" master
|
||||||
|
|
||||||
|
commit_with_assertion "touch ../test"
|
||||||
|
git checkout -b feature
|
||||||
|
git commit --allow-empty -m "feature"
|
||||||
|
|
||||||
|
run git-check-assertions
|
||||||
|
|
||||||
|
assert_success
|
||||||
|
assert_file_not_exists ../test
|
||||||
|
}
|
||||||
|
|
||||||
@test "should run all succeeding assertion blocks on the feature branch and finally return to the original branch" {
|
@test "should run all succeeding assertion blocks on the feature branch and finally return to the original branch" {
|
||||||
git checkout -b feature
|
git checkout -b feature
|
||||||
commit_with_assertion "touch ../test1"
|
commit_with_assertion "touch ../test1"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue