forked from toolshed/abra
		
	
		
			
				
	
	
		
			95 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			Bash
		
	
	
	
	
	
			
		
		
	
	
			95 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			Bash
		
	
	
	
	
	
#!/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
 | 
						|
}
 | 
						|
 | 
						|
teardown(){
 | 
						|
  if [[ -f "$ABRA_DIR/servers/$TEST_SERVER/foobar.$TEST_SERVER.env" ]]; then
 | 
						|
    run $ABRA app undeploy "foobar.$TEST_SERVER" --no-input
 | 
						|
    assert_success
 | 
						|
 | 
						|
    run $ABRA app rm "foobar.$TEST_SERVER" --no-input
 | 
						|
    assert_success
 | 
						|
  fi
 | 
						|
 | 
						|
  if [[ -d "$ABRA_DIR/recipes/foobar" ]]; then
 | 
						|
    run rm -rf "$ABRA_DIR/recipes/foobar"
 | 
						|
    assert_success
 | 
						|
  fi
 | 
						|
}
 | 
						|
 | 
						|
@test "create new recipe" {
 | 
						|
  run $ABRA recipe new foobar
 | 
						|
  assert_success
 | 
						|
  assert_output --partial "new recipe 'foobar' created"
 | 
						|
  assert_exists "$ABRA_DIR/recipes/foobar"
 | 
						|
 | 
						|
  run git -C "$ABRA_DIR/recipes/foobar" rev-parse --abbrev-ref HEAD
 | 
						|
  assert_success
 | 
						|
  assert_output "main"
 | 
						|
}
 | 
						|
 | 
						|
# bats test_tags=slow
 | 
						|
@test "create new app from new recipe" {
 | 
						|
  run $ABRA recipe new foobar
 | 
						|
  assert_success
 | 
						|
  assert_exists "$ABRA_DIR/recipes/foobar"
 | 
						|
 | 
						|
  run $ABRA app new foobar \
 | 
						|
    --no-input \
 | 
						|
    --server "$TEST_SERVER" \
 | 
						|
    --domain "foobar.$TEST_SERVER"
 | 
						|
  assert_success
 | 
						|
 | 
						|
  run $ABRA app deploy "foobar.$TEST_SERVER" --no-input
 | 
						|
  assert_success
 | 
						|
}
 | 
						|
 | 
						|
@test "create new recipe with git credentials" {
 | 
						|
  run $ABRA recipe new foobar --git-name fooUser --git-email foo@example.com
 | 
						|
  assert_success
 | 
						|
  assert_output --partial "new recipe 'foobar' created"
 | 
						|
  assert_exists "$ABRA_DIR/recipes/foobar"
 | 
						|
 | 
						|
  run bash -c 'git -C "$ABRA_DIR/recipes/foobar" log -n 1'
 | 
						|
  assert_success
 | 
						|
  assert_output --partial 'fooUser'
 | 
						|
  assert_output --partial 'foo@example.com'
 | 
						|
}
 | 
						|
 | 
						|
# bats test_tags=slow
 | 
						|
@test "recipe new, app new, no releases, latest commit" {
 | 
						|
  recipeName="foobar"
 | 
						|
 | 
						|
  run $ABRA recipe new "$recipeName"
 | 
						|
  assert_success
 | 
						|
  assert_exists "$ABRA_DIR/recipes/$recipeName"
 | 
						|
 | 
						|
  currentHash=$(git -C "$ABRA_DIR/recipes/$recipeName" show -s --format="%H")
 | 
						|
  domain="$recipeName.$TEST_APP_SERVER" 
 | 
						|
 | 
						|
  run $ABRA app new "$recipeName" \
 | 
						|
    --no-input \
 | 
						|
    --server "$TEST_SERVER" \
 | 
						|
    --domain "$domain"
 | 
						|
  assert_success
 | 
						|
  assert_output --partial "version: ${currentHash:0:8}"
 | 
						|
  assert_exists "$ABRA_DIR/servers/$TEST_SERVER/$domain.env"
 | 
						|
 | 
						|
  run grep -q "TYPE=$recipeName:${currentHash:0:8}" \
 | 
						|
    "$ABRA_DIR/servers/$TEST_SERVER/$domain.env"
 | 
						|
  assert_success
 | 
						|
}
 |