#!/usr/bin/env bash

_checkout_recipe() {
  run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" checkout .
  assert_success
}

_remove_tags(){
  run bash -c 'git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag -l | wc -l'
  assert_success
  refute_output '0'

  run bash -c 'git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag -l | \
    xargs -I{} git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag -d {}'
  assert_success
  assert_output --partial 'Deleted tag'

  run bash -c 'git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag -l | wc -l'
  assert_success
  assert_output '0'
}

_reset_tags() {
  run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" fetch --all
  assert_success

  run bash -c 'git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag -l | wc -l'
  assert_success
  refute_output '0'
}