test: use more plumbung for git output
This commit is contained in:
parent
91ea2c01a5
commit
43990b6fae
@ -13,6 +13,7 @@ teardown_file(){
|
||||
|
||||
setup(){
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
load "$PWD/tests/integration/helpers/git"
|
||||
_common_setup
|
||||
_fetch_recipe
|
||||
}
|
||||
@ -26,26 +27,9 @@ teardown(){
|
||||
run $ABRA app new --generate-bash-completion
|
||||
assert_success
|
||||
assert_output --partial "traefik"
|
||||
assert_output --partial "abra-test-recipe"
|
||||
|
||||
# Note: this test needs to be updated when a new version of the test recipe is published.
|
||||
run $ABRA app new abra-test-recipe --generate-bash-completion
|
||||
assert_success
|
||||
assert_output "0.1.0+1.20.0
|
||||
0.1.1+1.20.2
|
||||
0.2.0+1.21.0"
|
||||
}
|
||||
|
||||
@test "create new app" {
|
||||
_fetch_recipe
|
||||
_latest_tag
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" checkout $LATEST_TAG
|
||||
assert_success
|
||||
|
||||
_latest_hash
|
||||
_reset_recipe
|
||||
|
||||
run $ABRA app new "$TEST_RECIPE" \
|
||||
--no-input \
|
||||
--server "$TEST_SERVER" \
|
||||
@ -53,8 +37,9 @@ teardown(){
|
||||
assert_success
|
||||
assert_exists "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" log -1
|
||||
assert_output --partial "$LATEST_HASH"
|
||||
_get_head_hash
|
||||
_get_current_hash
|
||||
assert_equal "$headHash" "$currentHash"
|
||||
}
|
||||
|
||||
@test "create new app with version" {
|
||||
@ -65,8 +50,9 @@ teardown(){
|
||||
assert_success
|
||||
assert_exists "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" log -1
|
||||
assert_output --partial "453db7121c0a56a7a8f15378f18fe3bf21ccfdef"
|
||||
_get_tag_hash 0.1.1+1.20.2
|
||||
_get_current_hash
|
||||
assert_equal "$tagHash" "$currentHash"
|
||||
}
|
||||
|
||||
@test "does not overwrite existing env files" {
|
||||
@ -126,11 +112,14 @@ teardown(){
|
||||
}
|
||||
|
||||
@test "ensure recipe up to date if no --offline" {
|
||||
_reset_recipe
|
||||
_get_n_hash 3
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" reset --hard HEAD~3
|
||||
assert_success
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
assert_output --regexp 'behind .* 3 commits'
|
||||
_get_current_hash
|
||||
assert_equal "$currentHash" "$nHash"
|
||||
|
||||
run $ABRA app new "$TEST_RECIPE" \
|
||||
--no-input \
|
||||
@ -139,18 +128,22 @@ teardown(){
|
||||
assert_success
|
||||
assert_exists "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
assert_output --partial "up to date"
|
||||
_get_head_hash
|
||||
_get_current_hash
|
||||
assert_equal "$HEAD_HASH" "$CURRENT_HASH"
|
||||
|
||||
_reset_recipe
|
||||
}
|
||||
|
||||
@test "ensure recipe not up to date if --offline" {
|
||||
_reset_recipe
|
||||
_get_n_hash 3
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" reset --hard HEAD~3
|
||||
assert_success
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
assert_output --regexp 'behind .* 3 commits'
|
||||
_get_current_hash
|
||||
assert_equal "$currentHash" "$nHash"
|
||||
|
||||
# NOTE(d1): need to use --chaos to force same commit
|
||||
run $ABRA app new "$TEST_RECIPE" \
|
||||
@ -162,12 +155,13 @@ teardown(){
|
||||
assert_success
|
||||
assert_exists "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
assert_output --regexp 'behind .* 3 commits'
|
||||
_get_current_hash
|
||||
assert_equal "$currentHash" "$nHash"
|
||||
|
||||
_reset_recipe
|
||||
}
|
||||
|
||||
# bats test_tags=slow
|
||||
@test "generate secrets" {
|
||||
run $ABRA app new "$TEST_RECIPE" \
|
||||
--no-input \
|
||||
|
@ -37,14 +37,6 @@ _set_git_author() {
|
||||
assert_success
|
||||
}
|
||||
|
||||
_latest_tag() {
|
||||
export LATEST_TAG=$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" describe --abbrev=0)
|
||||
}
|
||||
|
||||
_latest_hash() {
|
||||
export LATEST_HASH=$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" log -1 --pretty=format:%h)
|
||||
}
|
||||
|
||||
_git_commit() {
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" add .
|
||||
assert_success
|
||||
@ -52,3 +44,23 @@ _git_commit() {
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" commit -m "test: helpers/git.bash: _git_commit"
|
||||
assert_success
|
||||
}
|
||||
|
||||
_get_tag_hash() {
|
||||
tagHash=$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" rev-list -n 1 "$1")
|
||||
assert_success
|
||||
}
|
||||
|
||||
_get_head_hash() {
|
||||
headHash=$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" show -s --format="%H" HEAD)
|
||||
assert_success
|
||||
}
|
||||
|
||||
_get_current_hash() {
|
||||
currentHash=$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" show -s --format="%H")
|
||||
assert_success
|
||||
}
|
||||
|
||||
_get_n_hash() {
|
||||
nHash=$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" show -s --format="%H" "HEAD~$1")
|
||||
assert_success
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user