test: no args for helpers, fix recipe_* tests [ci skip]

This commit is contained in:
decentral1se 2023-09-23 23:57:52 +02:00
parent ce7b4733d7
commit f0560ca975
Signed by: decentral1se
GPG Key ID: 03789458B3D0C410
12 changed files with 45 additions and 78 deletions

View File

@ -53,7 +53,7 @@ teardown(){
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
_checkout_recipe "$TEST_RECIPE"
_checkout_recipe
}
# bats test_tags=slow
@ -78,7 +78,7 @@ teardown(){
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
_checkout_recipe "$TEST_RECIPE"
_checkout_recipe
}
@test "ensure recipe up to date if no --offline" {
@ -142,7 +142,7 @@ teardown(){
assert_failure
assert_output --partial 'no backup config for app'
_checkout_recipe "$TEST_RECIPE"
_checkout_recipe
}
@test "error if backup paths not configured" {
@ -153,7 +153,7 @@ teardown(){
assert_failure
assert_output --partial 'backup paths are empty for app?'
_checkout_recipe "$TEST_RECIPE"
_checkout_recipe
}
# bats test_tags=slow

View File

@ -103,7 +103,7 @@ setup(){
assert_failure
assert_output --partial '.env.sample does not exist?'
_checkout_recipe "$TEST_RECIPE"
_checkout_recipe
}
@test "error if missing env var" {
@ -115,5 +115,5 @@ setup(){
assert_output --partial \
"$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env is missing NEW_VAR"
_checkout_recipe "$TEST_RECIPE"
_checkout_recipe
}

View File

@ -132,7 +132,7 @@ teardown(){
assert_failure
assert_output --partial "$ABRA_DIR/recipes/$TEST_RECIPE/abra.sh does not exist"
_checkout_recipe "$TEST_RECIPE"
_checkout_recipe
}
@test "error if missing command" {

View File

@ -51,7 +51,7 @@ teardown(){
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
_checkout_recipe "$TEST_RECIPE"
_checkout_recipe
}
# bats test_tags=slow
@ -174,7 +174,7 @@ teardown(){
assert_failure
assert_output --partial 'failed lint checks'
_checkout_recipe "$TEST_RECIPE"
_checkout_recipe
}
# bats test_tags=slow

View File

@ -60,7 +60,7 @@ teardown(){
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
_checkout_recipe "$TEST_RECIPE"
_checkout_recipe
}
# bats test_tags=slow
@ -100,7 +100,7 @@ teardown(){
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
_checkout_recipe "$TEST_RECIPE"
_checkout_recipe
}
@test "ensure recipe up to date if no --offline" {
@ -202,7 +202,7 @@ teardown(){
_undeploy_app
_checkout_recipe "$TEST_RECIPE"
_checkout_recipe
}
# bats test_tags=slow

View File

@ -158,7 +158,7 @@ teardown(){
_undeploy_app
_checkout_recipe "$TEST_RECIPE"
_checkout_recipe
}
@test "error if not already deployed" {

View File

@ -59,7 +59,7 @@ teardown(){
assert_failure
assert_output --partial 'failed lint checks'
_checkout_recipe "$TEST_RECIPE"
_checkout_recipe
_undeploy_app
}

View File

@ -53,7 +53,7 @@ teardown(){
assert_failure
assert_output --partial 'failed to determine'
_checkout_recipe "$TEST_RECIPE"
_checkout_recipe
_undeploy_app
}

View File

@ -67,12 +67,11 @@ setup() {
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
refute_output --partial 'behind 3'
_reset_recipe
}
@test "ensure recipe not up to date if --offline" {
latestCommit="$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" rev-parse --short HEAD)"
refute [ -z "$latestCommit" ];
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" reset --hard HEAD~3
assert_success
@ -85,11 +84,7 @@ setup() {
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
assert_output --partial 'behind 3'
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" checkout "$latestCommit"
assert_success
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
refute_output --partial 'behind 3'
_reset_recipe
}
@test "recipe lint warns on error" {
@ -103,5 +98,5 @@ setup() {
run $ABRA recipe lint "$TEST_RECIPE" --chaos
assert_success --partial 'watch out, some critical errors are present'
_checkout_recipe "$TEST_RECIPE"
_checkout_recipe
}

View File

@ -26,20 +26,14 @@ setup(){
assert_output --partial 'unable to validate recipe'
}
# NOTE(d1): relies on only 3 versions being published for the $TEST_RECIPE.
@test "release patch bump" {
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag --list
assert_success
assert_output '0.1.0+1.20.0'
run bash -c 'cat "$ABRA_DIR/recipes/$TEST_RECIPE/compose.yml" | grep -q "0.1.0+1.20.0"'
assert_success
run $ABRA recipe upgrade "$TEST_RECIPE" --no-input --patch
assert_success
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" diff
assert_success
assert_output --partial 'image: nginx:1.20.2'
assert_output --partial 'image: nginx:1.21.6'
run $ABRA recipe sync "$TEST_RECIPE" --no-input --patch
assert_success
@ -47,7 +41,7 @@ setup(){
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" diff
assert_success
assert_output --partial 'coop-cloud.${STACK_NAME}.version=0.1.1+1.20.2'
assert_output --partial 'coop-cloud.${STACK_NAME}.version=0.2.1+1.21.6'
run $ABRA recipe release "$TEST_RECIPE" --no-input --patch
assert_success
@ -55,27 +49,15 @@ setup(){
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag --list
assert_success
assert_output --partial '0.1.0+1.20.0'
assert_output --partial '0.1.1+1.20.2'
assert_output --partial '0.2.1+1.21.6'
_checkout_recipe "$TEST_RECIPE"
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" reset --hard HEAD~1
assert_success
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag -d '0.1.1+1.20.2'
assert_success
assert_output --partial "Deleted tag '0.1.1+1.20.2'"
_reset_recipe
}
# NOTE(d1): this test can't assert hardcoded versions since we upgrade a minor
# version which could be anything in the future. so, we do our best with
# --regexp.
@test "release minor bump" {
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag --list
assert_success
assert_output '0.1.0+1.20.0'
run bash -c 'grep -q "0.1.0+1.20.0" "$ABRA_DIR/recipes/$TEST_RECIPE/compose.yml"'
assert_success
run $ABRA recipe upgrade "$TEST_RECIPE" --no-input --minor
assert_success
@ -89,7 +71,7 @@ setup(){
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" diff
assert_success
assert_output --regexp 'coop-cloud\.\$\{STACK_NAME\}\.version=0\.2\.0\+1\.2.*'
assert_output --regexp 'coop-cloud\.\$\{STACK_NAME\}\.version=0\.3\.0\+1\.2.*'
run $ABRA recipe release "$TEST_RECIPE" --no-input --minor
assert_success
@ -97,8 +79,7 @@ setup(){
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag --list
assert_success
assert_output --partial '0.1.0+1.20.0'
assert_output --regexp '0\.2\.0\+1\.2.*'
assert_output --regexp '0\.3\.0\+1\.2.*'
_reset_recipe "$TEST_RECIPE"
}

View File

@ -41,7 +41,7 @@ setup(){
assert_success
assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
_checkout_recipe "$TEST_RECIPE"
_checkout_recipe
}
@test "detect unstaged label changes" {
@ -55,28 +55,26 @@ setup(){
assert_success
assert_output --partial 'is already set, nothing to do?'
_checkout_recipe "$TEST_RECIPE"
_checkout_recipe
}
# NOTE(d1): relies on only 3 versions being published for the $TEST_RECIPE.
@test "sync patch label bump" {
run bash -c 'cat "$ABRA_DIR/recipes/$TEST_RECIPE/compose.yml" | grep -q "0.1.0+1.20.0"'
assert_success
run $ABRA recipe upgrade "$TEST_RECIPE" --no-input --patch
assert_success
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" diff
assert_success
assert_output --partial 'image: nginx:1.20.2'
assert_output --partial 'image: nginx:1.21.6'
run $ABRA recipe sync "$TEST_RECIPE" --no-input --patch
assert_success
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" diff
assert_success
assert_output --partial 'coop-cloud.${STACK_NAME}.version=0.1.1+1.20.2'
assert_output --partial 'coop-cloud.${STACK_NAME}.version=0.2.1+1.21.6'
_checkout_recipe "$TEST_RECIPE"
_checkout_recipe
}
@test "sync minor label bump" {
@ -94,22 +92,18 @@ setup(){
assert_success
assert_output --regexp 'coop-cloud\.\$\{STACK_NAME\}\.version=0\.2\.0\+1\.2.*'
_checkout_recipe "$TEST_RECIPE"
_checkout_recipe
}
@test "error if --no-input and no initial version" {
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag -d '0.1.0+1.20.0'
assert_success
assert_output --partial "Deleted tag '0.1.0+1.20.0'"
_remove_tags
run $ABRA recipe sync "$TEST_RECIPE" --no-input --patch
assert_failure
assert_output --partial 'unable to continue'
assert_output --partial 'initial version'
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" fetch -a
assert_success
assert_output --partial '[new tag]'
_reset_tags
}
@test "output label sync only once" {
@ -125,5 +119,5 @@ setup(){
assert_line --index 0 --partial 'synced label'
refute_line --index 1 --partial 'synced label'
_checkout_recipe "$TEST_RECIPE"
_checkout_recipe
}

View File

@ -68,6 +68,8 @@ setup(){
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
refute_output --partial 'behind 3'
_reset_recipe
}
@test "only one of -x/y/z flags" {
@ -76,24 +78,19 @@ setup(){
assert_output --partial 'you can only use one of'
}
# NOTE(d1): relies on only 3 versions being published for the $TEST_RECIPE.
@test "upgrade patch" {
run bash -c 'cat "$ABRA_DIR/recipes/$TEST_RECIPE/compose.yml" | grep -q "0.1.0+1.20.0"'
assert_success
run $ABRA recipe upgrade "$TEST_RECIPE" --no-input --patch
assert_success
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" diff
assert_success
assert_output --partial 'image: nginx:1.20.2'
assert_output --partial 'image: nginx:1.21.6'
_checkout_recipe "$TEST_RECIPE"
_checkout_recipe
}
@test "upgrade minor" {
run bash -c 'cat "$ABRA_DIR/recipes/$TEST_RECIPE/compose.yml" | grep -q "0.1.0+1.20.0"'
assert_success
run $ABRA recipe upgrade "$TEST_RECIPE" --no-input --minor
assert_success
@ -101,5 +98,5 @@ setup(){
assert_success
assert_output --regexp 'image: nginx:1.2.*'
_checkout_recipe "$TEST_RECIPE"
_checkout_recipe
}