#!/usr/bin/env bash

setup_file(){
  load "$PWD/tests/integration/helpers/common"
  _common_setup
  _add_server
  _new_app
}

teardown_file(){
  _rm_app
  _rm_server
}

setup(){
  load "$PWD/tests/integration/helpers/common"
  _common_setup
}

@test "validate app argument" {
  run $ABRA app logs
  assert_failure

  run $ABRA app logs DOESNTEXIST
  assert_failure
}

@test "error if not deployed" {
  run $ABRA app logs "$TEST_APP_DOMAIN"
  assert_failure
  assert_output --partial 'is not deployed'
}

@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 app logs "$TEST_APP_DOMAIN"
  assert_failure
  assert_output --partial 'is not deployed'

  assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE"
}
