#!/usr/bin/env bash setup_file(){ load "$PWD/tests/integration/helpers/common" _common_setup _add_server } teardown_file(){ _rm_server } setup(){ load "$PWD/tests/integration/helpers/common" _common_setup _fetch_recipe } teardown(){ _rm_app } @test "create new app" { run $ABRA app new "$TEST_RECIPE" \ --no-input \ --server "$TEST_SERVER" \ --domain "$TEST_APP_DOMAIN" assert_success assert_exists "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env" } @test "does not overwrite existing env files" { _new_app run $ABRA app new "$TEST_RECIPE" \ --no-input \ --server "$TEST_SERVER" \ --domain "$TEST_APP_DOMAIN" assert_failure assert_output --partial 'already exists' } @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 app new "$TEST_RECIPE" \ --no-input \ --server "$TEST_SERVER" \ --domain "$TEST_APP_DOMAIN" 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 "unstaged changes" >> "$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 app new "$TEST_RECIPE" \ --no-input \ --chaos \ --server "$TEST_SERVER" \ --domain "$TEST_APP_DOMAIN" \ --secrets assert_success assert_exists "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env" 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 --partial 'behind 3' run $ABRA app new "$TEST_RECIPE" \ --no-input \ --server "$TEST_SERVER" \ --domain "$TEST_APP_DOMAIN" \ --secrets assert_success assert_exists "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env" 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" { 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 --partial 'behind 3' # NOTE(d1): need to use --chaos to force same commit run $ABRA app new "$TEST_RECIPE" \ --no-input \ --offline \ --chaos \ --server "$TEST_SERVER" \ --domain "$TEST_APP_DOMAIN" \ --secrets 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 'behind 3' _reset_recipe } @test "generate secrets" { run $ABRA app new "$TEST_RECIPE" \ --no-input \ --server "$TEST_SERVER" \ --domain "$TEST_APP_DOMAIN" \ --secrets assert_success assert_output --partial 'generated secrets' assert_output --partial 'test_password' assert_exists "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env" run $ABRA app secret ls "$TEST_APP_DOMAIN" assert_success assert_output --partial 'test_password' }