#!/usr/bin/env bash teardown_file() { load "$PWD/tests/integration/helpers/common" _common_setup _reset_recipe } setup() { load "$PWD/tests/integration/helpers/common" _common_setup } @test "recipe lint" { run $ABRA recipe lint gitea assert_success assert_output --partial 'compose config has expected version' } @test "retrieve recipe if missing" { run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE" assert_success assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE" run $ABRA recipe lint "$TEST_RECIPE" assert_success assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE" } @test "bail if unstaged changes and no --chaos" { run bash -c "echo foo >> $ABRA_DIR/recipes/$TEST_RECIPE/foo" assert_success assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status assert_success assert_output --partial 'foo' run $ABRA recipe lint "$TEST_RECIPE" assert_failure assert_output --partial 'locally unstaged changes' run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo" assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" } @test "do not bail if unstaged changes and --chaos" { run bash -c "echo foo >> $ABRA_DIR/recipes/$TEST_RECIPE/foo" assert_success assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status assert_success assert_output --partial 'foo' run $ABRA recipe lint "$TEST_RECIPE" --chaos assert_success run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo" assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" } @test "ensure recipe up to date if no --offline" { 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' run $ABRA recipe lint "$TEST_RECIPE" assert_success run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status assert_output --regexp 'behind .* 3 commits' _reset_recipe } @test "ensure recipe not up to date if --offline" { 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' run $ABRA recipe lint "$TEST_RECIPE" --offline assert_success run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status assert_output --regexp 'behind .* 3 commits' _reset_recipe } @test "recipe lint warns on error" { run $ABRA recipe lint "$TEST_RECIPE" assert_success refute_output --partial 'watch out, some critical errors are present' run sed -i '/traefik.enable=.*/d' "$ABRA_DIR/recipes/$TEST_RECIPE/compose.yml" assert_success run $ABRA recipe lint "$TEST_RECIPE" --chaos assert_success --partial 'watch out, some critical errors are present' _checkout_recipe }