#!/usr/bin/env bash setup(){ load "$PWD/tests/integration/helpers/common" _common_setup } # bats test_tags=slow @test "generate catalogue" { run $ABRA catalogue generate assert_success for d in $(ls $ABRA_DIR/recipes); do assert_exists "$ABRA_DIR/recipes/$d/.git" done } @test "error if unstaged changes" { run bash -c "echo foo >> $ABRA_DIR/catalogue/foo" assert_success assert_exists "$ABRA_DIR/catalogue/foo" run $ABRA catalogue generate assert_failure assert_output --partial 'locally unstaged changes' run rm -rf "$ABRA_DIR/catalogue/foo" assert_not_exists "$ABRA_DIR/catalogue/foo" } # bats test_tags=slow @test "no error if unstaged and --chaos" { run bash -c "echo foo >> $ABRA_DIR/catalogue/foo" assert_success assert_exists "$ABRA_DIR/catalogue/foo" run $ABRA catalogue generate gitea --chaos assert_success run rm -rf "$ABRA_DIR/catalogue/foo" assert_not_exists "$ABRA_DIR/catalogue/foo" } # bats test_tags=slow @test "generate only specific recipe" { run $ABRA catalogue generate gitea assert_success assert_exists "$ABRA_DIR/recipes/gitea/.git" } # bats test_tags=slow @test "sync latest changes" { _ensure_catalogue latestHash=$(git -C "$ABRA_DIR/catalogue" show -s --format="%H") wantHash=$(git -C "$ABRA_DIR/catalogue" show -s --format="%H" "HEAD~3") run git -C "$ABRA_DIR/catalogue" reset --hard HEAD~3 assert_success currHash=$(git -C "$ABRA_DIR/catalogue" show -s --format="%H") assert_equal "$currHash" "$wantHash" run $ABRA catalogue sync assert_success syncHash=$(git -C "$ABRA_DIR/catalogue" show -s --format="%H") assert_equal "$syncHash" "$latestHash" }