#!/usr/bin/env bash

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

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


@test "recipe versions" {
  run $ABRA recipe versions gitea
  assert_success
  assert_output --partial '2.3.2+1.20.3-rootless'
}

@test "local tags used if no catalogue entry" {
  run $ABRA recipe versions "$TEST_RECIPE"
  assert_success
  assert_output --partial "$(_latest_release)"
}

@test "versions listed in correct order" {
  latestVersion=$(jq -r '.gitea.versions[-1] | keys[0]' < "$ABRA_DIR/catalogue/recipes.json")
  refute [ -z "$latestVersion" ];

  run bash -c '$ABRA recipe versions gitea --machine | jq -r ".[0].version" | head -n 1'
  assert_success
  assert_output "$latestVersion"
}
