#!/usr/bin/env bash

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

teardown_file(){
  _rm_app
  _rm_server
  _reset_recipe
}

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

teardown(){
  _undeploy_app
}

@test "validate app argument" {
  run $ABRA app services
  assert_failure
  assert_output --partial 'no app provided'

  run $ABRA app services DOESNTEXIST
  assert_failure
  assert_output --partial 'cannot find app'
}

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

# bats test_tags=slow
@test "list services" {
  _deploy_app

  run $ABRA app services "$TEST_APP_DOMAIN"
  assert_success

  sanitisedDomainName="${TEST_APP_DOMAIN//./_}"
  assert_output --partial "$sanitisedDomainName_app"
  assert_output --partial "nginx"
}
