#!/usr/bin/env bash

_add_server() {
  if [[ "$TEST_SERVER" == "default" ]]; then
      run $ABRA server add -l
  else
      run $ABRA server add "$TEST_SERVER"
  fi
  assert_success
  assert_exists "$ABRA_DIR/servers/$TEST_SERVER"
}

_add_move_server() {
  run docker context create default2 --docker "host=unix:///var/run/docker.sock"
  assert_success

  run mkdir -p "$ABRA_DIR/servers/default2"
  assert_success
  assert_exists "$ABRA_DIR/servers/default2"
}

_rm_server() {
  if [[ "$TEST_SERVER" == "default" ]]; then
      run rm -rf "$ABRA_DIR/servers/default"
  else
      run $ABRA server remove --no-input "$TEST_SERVER"
  fi
  assert_success
  assert_not_exists "$ABRA_DIR/servers/$TEST_SERVER"
}

_rm_move_server() {
  run docker context rm default2
  assert_success

  run rm -rf "$ABRA_DIR/servers/default2"
  assert_success
  assert_not_exists "$ABRA_DIR/servers/default2"
}

_rm_default_server(){
  run rm -rf "$ABRA_DIR/servers/default"
  assert_success
  assert_not_exists "$ABRA_DIR/servers/default"
}
