#!/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
}

@test "validate server" {
  run $ABRA server prune --no-input
  assert_failure
  assert_output --partial 'no server provided'

  run $ABRA server prune foo
  assert_failure
  assert_output --partial "server doesn't exist"
}

@test "prune containers, networks and images" {
  run $ABRA server prune "$TEST_SERVER"
  assert_success
  assert_output --partial 'containers pruned'
  assert_output --partial 'networks pruned'
  assert_output --partial 'images pruned'
}

@test "prune all images" {
  run $ABRA server prune "$TEST_SERVER" --all --debug
  assert_success
  assert_output --partial 'removing all images, not only dangling ones'
}

@test "prune volumes" {
  run $ABRA server prune "$TEST_SERVER" --volumes
  assert_success
  assert_output --partial 'volumes pruned'
}
