Skip to content

Commit

Permalink
test: revert some of edge-cases of test
Browse files Browse the repository at this point in the history
  • Loading branch information
dalisoft committed Apr 25, 2024
1 parent 5f9e655 commit 0db99e0
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 8 deletions.
19 changes: 18 additions & 1 deletion tests/plugins/changelog.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,20 @@ setup_suite() {
git init --quiet --initial-branch=master

export GIT_DIR="$REPO_FOLDER/.git"
export GIT_CONFIG="$GIT_DIR/.gitconfig"
export GIT_CONFIG="$REPO_FOLDER/.gitconfig"
export GIT_WORK_TREE="$REPO_FOLDER"

if [[ -n "${GIT_USERNAME-}" && -n "${GIT_EMAIL-}" ]]; then
export GIT_COMMITTER_NAME="$GIT_USERNAME"
export GIT_COMMITTER_EMAIL="$GIT_EMAIL"
export GIT_AUTHOR_NAME="$GIT_USERNAME"
export GIT_AUTHOR_EMAIL="$GIT_EMAIL"

git config user.email "$GIT_EMAIL"
git config user.name "$GIT_USERNAME"
fi

export GPG_NO_SIGN=1
}

teardown_suite() {
Expand All @@ -19,6 +31,11 @@ teardown_suite() {
unset GIT_DIR
unset GIT_CONFIG
unset GIT_WORK_TREE

unset GIT_COMMITTER_NAME
unset GIT_COMMITTER_EMAIL
unset GIT_AUTHOR_NAME
unset GIT_AUTHOR_EMAIL
}

#####################################
Expand Down
22 changes: 19 additions & 3 deletions tests/plugins/github-release.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,27 @@ setup_suite() {
unset GITHUB_TOKEN

export GIT_DIR="$REPO_FOLDER/.git"
export GIT_CONFIG="$GIT_DIR/.gitconfig"
export GIT_CONFIG="$REPO_FOLDER/.gitconfig"
export GIT_WORK_TREE="$REPO_FOLDER"

if [[ -n "${GIT_USERNAME-}" && -n "${GIT_EMAIL-}" ]]; then
export GIT_COMMITTER_NAME="$GIT_USERNAME"
export GIT_COMMITTER_EMAIL="$GIT_EMAIL"
export GIT_AUTHOR_NAME="$GIT_USERNAME"
export GIT_AUTHOR_EMAIL="$GIT_EMAIL"

git config user.email "$GIT_EMAIL"
git config user.name "$GIT_USERNAME"
fi

fake_curl() {
# shellcheck disable=SC2317
echo "${GITHUB_TOKEN-}"
# shellcheck disable=SC2317
echo "${FAKE_PARAMS[@]}"
}
export -f fake_curl
export GPG_NO_SIGN=1

fake curl fake_curl
}
Expand All @@ -35,6 +46,11 @@ teardown_suite() {
unset GIT_DIR
unset GIT_CONFIG
unset GIT_WORK_TREE

unset GIT_COMMITTER_NAME
unset GIT_COMMITTER_EMAIL
unset GIT_AUTHOR_NAME
unset GIT_AUTHOR_EMAIL
}

#####################################
Expand All @@ -43,7 +59,7 @@ teardown_suite() {
#####################################

test_plugin_gh_0_1_initial_message_dryrun() {
git commit --quiet -m "fix: initial commit" --allow-empty
git commit --quiet -m "fix: initial commit" --allow-empty --no-gpg-sign

GITHUB_TOKEN="FAKE_TOKEN" bash "$ROOT_DIR/release.sh" --plugins=git,github-release --quiet --dry-run --pre-release
assert_not_matches "v0.0.1" "$(git tag -l)"
Expand All @@ -53,7 +69,7 @@ test_plugin_gh_0_2_initial_message() {
assert_matches "v0.0.1" "$(git tag -l)"
}
test_plugin_gh_no_token_fail_message() {
git commit --quiet -m "fix: initial commit" --allow-empty
git commit --quiet -m "fix: initial commit" --allow-empty --no-gpg-sign

assert_matches "v0.0.1" "$(git tag -l)"
assert_not_matches "v0.0.2" "$(git tag -l)"
Expand Down
19 changes: 18 additions & 1 deletion tests/plugins/npm-post.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,21 @@ setup_suite() {
' >>"$REPO_FOLDER/package.json"

export GIT_DIR="$REPO_FOLDER/.git"
export GIT_CONFIG="$GIT_DIR/.gitconfig"
export GIT_CONFIG="$REPO_FOLDER/.gitconfig"
export GIT_WORK_TREE="$REPO_FOLDER"

if [[ -n "${GIT_USERNAME-}" && -n "${GIT_EMAIL-}" ]]; then
export GIT_COMMITTER_NAME="$GIT_USERNAME"
export GIT_COMMITTER_EMAIL="$GIT_EMAIL"
export GIT_AUTHOR_NAME="$GIT_USERNAME"
export GIT_AUTHOR_EMAIL="$GIT_EMAIL"

git config user.email "$GIT_EMAIL"
git config user.name "$GIT_USERNAME"
fi

export GPG_NO_SIGN=1

_npm() {
# shellcheck disable=SC2317
if [[ "${FAKE_PARAMS[0]}" == "publish" && "${NPM_TOKEN-}" == "FAKE_TOKEN" ]]; then
Expand All @@ -49,6 +61,11 @@ teardown_suite() {
unset GIT_DIR
unset GIT_CONFIG
unset GIT_WORK_TREE

unset GIT_COMMITTER_NAME
unset GIT_COMMITTER_EMAIL
unset GIT_AUTHOR_NAME
unset GIT_AUTHOR_EMAIL
}

#####################################
Expand Down
20 changes: 18 additions & 2 deletions tests/plugins/npm.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,19 @@ setup_suite() {
' >>"$REPO_FOLDER/package.json"

export GIT_DIR="$REPO_FOLDER/.git"
export GIT_CONFIG="$GIT_DIR/.gitconfig"
export GIT_CONFIG="$REPO_FOLDER/.gitconfig"
export GIT_WORK_TREE="$REPO_FOLDER"

if [[ -n "${GIT_USERNAME-}" && -n "${GIT_EMAIL-}" ]]; then
export GIT_COMMITTER_NAME="$GIT_USERNAME"
export GIT_COMMITTER_EMAIL="$GIT_EMAIL"
export GIT_AUTHOR_NAME="$GIT_USERNAME"
export GIT_AUTHOR_EMAIL="$GIT_EMAIL"

git config user.email "$GIT_EMAIL"
git config user.name "$GIT_USERNAME"
fi

_npm() {
# shellcheck disable=SC2317
if [[ "${FAKE_PARAMS[0]}" == "publish" && "${NPM_TOKEN-}" == "FAKE_TOKEN" ]]; then
Expand All @@ -39,6 +49,7 @@ setup_suite() {
fi
}
export -f _npm
export GPG_NO_SIGN=1

fake npm _npm
}
Expand All @@ -49,6 +60,11 @@ teardown_suite() {
unset GIT_DIR
unset GIT_CONFIG
unset GIT_WORK_TREE

unset GIT_COMMITTER_NAME
unset GIT_COMMITTER_EMAIL
unset GIT_AUTHOR_NAME
unset GIT_AUTHOR_EMAIL
}

#####################################
Expand All @@ -57,7 +73,7 @@ teardown_suite() {
#####################################

test_plugin_npm_0_1_initial_message_dryrun() {
git commit --quiet -m "fix: initial commit" --allow-empty
git commit --quiet -m "fix: initial commit" --allow-empty --no-gpg-sign

NPM_TOKEN="FAKE_TOKEN" bash "$ROOT_DIR/release.sh" --plugins=npm --quiet --dry-run
assert_matches "1.0.0" "$(cat package.json)"
Expand Down
19 changes: 18 additions & 1 deletion tests/plugins/template.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,20 @@ setup_suite() {
git init --quiet --initial-branch=master

export GIT_DIR="$REPO_FOLDER/.git"
export GIT_CONFIG="$GIT_DIR/.gitconfig"
export GIT_CONFIG="$REPO_FOLDER/.gitconfig"
export GIT_WORK_TREE="$REPO_FOLDER"

if [[ -n "${GIT_USERNAME-}" && -n "${GIT_EMAIL-}" ]]; then
export GIT_COMMITTER_NAME="$GIT_USERNAME"
export GIT_COMMITTER_EMAIL="$GIT_EMAIL"
export GIT_AUTHOR_NAME="$GIT_USERNAME"
export GIT_AUTHOR_EMAIL="$GIT_EMAIL"

git config user.email "$GIT_EMAIL"
git config user.name "$GIT_USERNAME"
fi

export GPG_NO_SIGN=1
}

teardown_suite() {
Expand All @@ -19,6 +31,11 @@ teardown_suite() {
unset GIT_DIR
unset GIT_CONFIG
unset GIT_WORK_TREE

unset GIT_COMMITTER_NAME
unset GIT_COMMITTER_EMAIL
unset GIT_AUTHOR_NAME
unset GIT_AUTHOR_EMAIL
}

#####################################
Expand Down

0 comments on commit 0db99e0

Please sign in to comment.