#!/usr/bin/env bash

assert "mise x ubi:goreleaser/goreleaser@v1.25.0 -- goreleaser -v | grep -o 1.25.0" "1.25.0"

mise use ubi:kellyjonbrazil/jc@1.25.3
assert_contains "$MISE_DATA_DIR/shims/jc --version" "jc version:  1.25.3"

cat <<EOF >mise.toml
[tools]
"ubi:cilium/cilium-cli" = { version = "latest", exe = "cilium" }
EOF
# re-uses tool options
mise use ubi:cilium/cilium-cli
assert "cat mise.toml" '[tools]
"ubi:cilium/cilium-cli" = { version = "latest", exe = "cilium" }'

MISE_USE_VERSIONS_HOST=0 assert_not_contains "mise ls-remote cargo-binstall" "binstalk"

# the following tests that tool options from ubi are still retained even if the default backend changes to aqua
assert "MISE_DISABLE_BACKENDS=aqua mise use gh"
cat "$MISE_DATA_DIR/installs/gh/.mise.backend"
assert_contains "mise tool gh" "ubi:cli/cli[exe=gh]"
assert "mise i -f gh"
cat "$MISE_DATA_DIR/installs/gh/.mise.backend"
assert_contains "mise tool gh" "ubi:cli/cli[exe=gh]"
