forked from toolshed/abra
test: tag/git helpers & refactor [ci skip]
This commit is contained in:
parent
575bfbb0fb
commit
ce7b4733d7
@ -94,6 +94,8 @@ teardown(){
|
|||||||
|
|
||||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||||
refute_output --partial 'behind 3'
|
refute_output --partial 'behind 3'
|
||||||
|
|
||||||
|
_reset_recipe "$TEST_RECIPE"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "ensure recipe not up to date if --offline" {
|
@test "ensure recipe not up to date if --offline" {
|
||||||
@ -118,6 +120,8 @@ teardown(){
|
|||||||
|
|
||||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||||
refute_output --partial 'behind 3'
|
refute_output --partial 'behind 3'
|
||||||
|
|
||||||
|
_reset_recipe "$TEST_RECIPE"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "detect backup labels" {
|
@test "detect backup labels" {
|
||||||
|
@ -75,12 +75,11 @@ setup(){
|
|||||||
|
|
||||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||||
refute_output --partial 'behind 3'
|
refute_output --partial 'behind 3'
|
||||||
|
|
||||||
|
_reset_recipe "$TEST_RECIPE"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "ensure recipe not up to date if --offline" {
|
@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
|
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" reset --hard HEAD~3
|
||||||
assert_success
|
assert_success
|
||||||
|
|
||||||
@ -93,11 +92,7 @@ setup(){
|
|||||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||||
assert_output --partial 'behind 3'
|
assert_output --partial 'behind 3'
|
||||||
|
|
||||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" checkout "$latestCommit"
|
_reset_recipe "$TEST_RECIPE"
|
||||||
assert_success
|
|
||||||
|
|
||||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
|
||||||
refute_output --partial 'behind 3'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "error if missing .env.sample" {
|
@test "error if missing .env.sample" {
|
||||||
|
@ -85,12 +85,11 @@ teardown(){
|
|||||||
|
|
||||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||||
refute_output --partial 'behind 3'
|
refute_output --partial 'behind 3'
|
||||||
|
|
||||||
|
_reset_recipe "$TEST_RECIPE"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "ensure recipe not up to date if --offline" {
|
@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
|
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" reset --hard HEAD~3
|
||||||
assert_success
|
assert_success
|
||||||
|
|
||||||
@ -104,11 +103,7 @@ teardown(){
|
|||||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||||
assert_output --partial 'behind 3'
|
assert_output --partial 'behind 3'
|
||||||
|
|
||||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" checkout "$latestCommit"
|
_reset_recipe "$TEST_RECIPE"
|
||||||
assert_success
|
|
||||||
|
|
||||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
|
||||||
refute_output --partial 'behind 3'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "error if missing arguments without passing --local" {
|
@test "error if missing arguments without passing --local" {
|
||||||
|
@ -86,12 +86,7 @@ teardown(){
|
|||||||
run $ABRA app deploy "$TEST_APP_DOMAIN" --no-input --no-converge-checks
|
run $ABRA app deploy "$TEST_APP_DOMAIN" --no-input --no-converge-checks
|
||||||
assert_success
|
assert_success
|
||||||
|
|
||||||
# NOTE(d1): nuke it to ensure clean git state
|
_reset_recipe "$TEST_RECIPE"
|
||||||
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE"
|
|
||||||
assert_success
|
|
||||||
assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE"
|
|
||||||
_fetch_recipe "$TEST_RECIPE"
|
|
||||||
|
|
||||||
_undeploy_app
|
_undeploy_app
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,30 +107,14 @@ teardown(){
|
|||||||
assert_output --partial 'behind 3'
|
assert_output --partial 'behind 3'
|
||||||
|
|
||||||
_undeploy_app
|
_undeploy_app
|
||||||
|
_reset_recipe "$TEST_RECIPE"
|
||||||
# NOTE(d1): nuke it to ensure clean git state
|
|
||||||
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE"
|
|
||||||
assert_success
|
|
||||||
assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE"
|
|
||||||
_fetch_recipe "$TEST_RECIPE"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# bats test_tags=slow
|
# bats test_tags=slow
|
||||||
@test "deploy latest commit if no published versions and no --chaos" {
|
@test "deploy latest commit if no published versions and no --chaos" {
|
||||||
latestCommit="$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" rev-parse --short HEAD)"
|
latestCommit="$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" rev-parse --short HEAD)"
|
||||||
|
|
||||||
run bash -c 'git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag -l | wc -l'
|
_remove_tags
|
||||||
assert_success
|
|
||||||
refute_output '0'
|
|
||||||
|
|
||||||
run bash -c 'git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag -l | \
|
|
||||||
xargs -I{} git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag -d {}'
|
|
||||||
assert_success
|
|
||||||
assert_output --partial 'Deleted tag'
|
|
||||||
|
|
||||||
run bash -c 'git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag -l | wc -l'
|
|
||||||
assert_success
|
|
||||||
assert_output '0'
|
|
||||||
|
|
||||||
# NOTE(d1): need to pass --offline to stop tags being pulled again
|
# NOTE(d1): need to pass --offline to stop tags being pulled again
|
||||||
run $ABRA app deploy "$TEST_APP_DOMAIN" \
|
run $ABRA app deploy "$TEST_APP_DOMAIN" \
|
||||||
@ -146,13 +125,7 @@ teardown(){
|
|||||||
refute_output --partial 'chaos'
|
refute_output --partial 'chaos'
|
||||||
|
|
||||||
_undeploy_app
|
_undeploy_app
|
||||||
|
_reset_tags
|
||||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" fetch --all
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
run bash -c 'git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag -l | wc -l'
|
|
||||||
assert_success
|
|
||||||
refute_output '0'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# bats test_tags=slow
|
# bats test_tags=slow
|
||||||
@ -175,12 +148,7 @@ teardown(){
|
|||||||
assert_output --partial 'chaos'
|
assert_output --partial 'chaos'
|
||||||
|
|
||||||
_undeploy_app
|
_undeploy_app
|
||||||
|
_reset_recipe
|
||||||
# NOTE(d1): nuke it to ensure clean git state
|
|
||||||
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE"
|
|
||||||
assert_success
|
|
||||||
assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE"
|
|
||||||
_fetch_recipe "$TEST_RECIPE"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# bats test_tags=slow
|
# bats test_tags=slow
|
||||||
|
@ -78,11 +78,7 @@ teardown(){
|
|||||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" checkout "$latestCommit"
|
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" checkout "$latestCommit"
|
||||||
assert_success
|
assert_success
|
||||||
|
|
||||||
# NOTE(d1): nuke it to ensure clean git state
|
_reset_recipe "$TEST_RECIPE"
|
||||||
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE"
|
|
||||||
assert_success
|
|
||||||
assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE"
|
|
||||||
_fetch_recipe "$TEST_RECIPE"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "bail if unstaged changes and no --chaos" {
|
@test "bail if unstaged changes and no --chaos" {
|
||||||
|
@ -1,11 +1,30 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
_checkout_recipe() {
|
_checkout_recipe() {
|
||||||
if [[ -z "$1" ]]; then
|
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" checkout .
|
||||||
echo 'forgot to pass argument to function?'
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
run git -C "$ABRA_DIR/recipes/$1" checkout .
|
|
||||||
assert_success
|
assert_success
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_remove_tags(){
|
||||||
|
run bash -c 'git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag -l | wc -l'
|
||||||
|
assert_success
|
||||||
|
refute_output '0'
|
||||||
|
|
||||||
|
run bash -c 'git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag -l | \
|
||||||
|
xargs -I{} git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag -d {}'
|
||||||
|
assert_success
|
||||||
|
assert_output --partial 'Deleted tag'
|
||||||
|
|
||||||
|
run bash -c 'git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag -l | wc -l'
|
||||||
|
assert_success
|
||||||
|
assert_output '0'
|
||||||
|
}
|
||||||
|
|
||||||
|
_reset_tags() {
|
||||||
|
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" fetch --all
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run bash -c 'git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag -l | wc -l'
|
||||||
|
assert_success
|
||||||
|
refute_output '0'
|
||||||
|
}
|
||||||
|
@ -1,16 +1,19 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
_fetch_recipe() {
|
_fetch_recipe() {
|
||||||
if [[ -z "$1" ]]; then
|
if [[ ! -d "$ABRA_DIR/recipes/$TEST_RECIPE" ]]; then
|
||||||
echo 'forgot to pass argument to function?'
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ ! -d "$ABRA_DIR/recipes/$1" ]]; then
|
|
||||||
run mkdir -p "$ABRA_DIR/recipes"
|
run mkdir -p "$ABRA_DIR/recipes"
|
||||||
assert_success
|
assert_success
|
||||||
|
|
||||||
run git clone "https://git.coopcloud.tech/coop-cloud/$1" "$ABRA_DIR/recipes/$1"
|
run git clone "https://git.coopcloud.tech/coop-cloud/$TEST_RECIPE" "$ABRA_DIR/recipes/$TEST_RECIPE"
|
||||||
assert_success
|
assert_success
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_reset_recipe(){
|
||||||
|
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE"
|
||||||
|
assert_success
|
||||||
|
assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE"
|
||||||
|
|
||||||
|
_fetch_recipe
|
||||||
|
}
|
||||||
|
@ -100,8 +100,5 @@ setup(){
|
|||||||
assert_output --partial '0.1.0+1.20.0'
|
assert_output --partial '0.1.0+1.20.0'
|
||||||
assert_output --regexp '0\.2\.0\+1\.2.*'
|
assert_output --regexp '0\.2\.0\+1\.2.*'
|
||||||
|
|
||||||
# NOTE(d1): nuke it since we can't clean up the tag
|
_reset_recipe "$TEST_RECIPE"
|
||||||
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE"
|
|
||||||
assert_success
|
|
||||||
assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE"
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user