#!/usr/bin/env bash
# shellcheck disable=SC2016

# TODO: fix this in CI
#orig_path="$PATH"
#
#cat <<EOF >.mise.toml
#[tools]
#tiny = "3.1.0"
#[env]
#FOO = "bar"
#EOF
#
#mkdir subdir
#cat <<EOF >subdir/.mise.toml
#[tools]
#tiny = "2.0.0"
#[env]
#FOO = "quz"
#EOF
#
#eval "$(mise activate bash --status)" && _mise_hook
#
#assert_path() {
#  local actual="${PATH/%$orig_path/}"
#  actual="${actual%:}"
#  actual="${actual%:}"
#  actual="${actual//$MISE_DATA_DIR\/installs/INSTALLS}"
#  actual="${actual//$HOME/HOME}"
#  assert "echo $actual" "$1"
#}
#
#TINY_310="INSTALLS/tiny/3.1.0/bin"
#TINY_200="INSTALLS/tiny/2.0.0/bin"
#
#mise ls
#mise i && _mise_hook
#
#echo "$PATH"
#
#assert_contains "rtx-tiny" "v3.1.0"
#assert 'echo $FOO' "bar"
#assert_path "$TINY_310"
#
#cd subdir && mise i && _mise_hook
#assert_contains "rtx-tiny" "v2.0.0"
#assert 'echo $FOO' "quz"
#assert_path "$TINY_200"
#
#cd .. && _mise_hook
#assert_contains "rtx-tiny" "v3.1.0"
#assert 'echo $FOO' "bar"
#assert_path "$TINY_310"
#
#export PATH="PRE:$PATH"
#cd subdir && _mise_hook
#assert_contains "rtx-tiny" "v2.0.0"
#assert 'echo $FOO' "quz"
#assert_path "PRE:$TINY_200"
#
#mise shell tiny@3.0.0 && _mise_hook
#assert_contains "rtx-tiny" "v3.0.0"
#
#mise deactivate
#assert_path "PRE"
