#!/usr/bin/env bash

mise i dummy@1.0.0 tiny@1.0.0

eval "$(mise activate bash --status)"

mise shell dummy@1.0.0 tiny@1.0.0
assert "echo $MISE_DUMMY_VERSION" "1.0.0"
assert "echo $MISE_TINY_VERSION" "1.0.0"

# a variable exported by hand is a tool override too, so --all removes it
export MISE_NODEJS_VERSION=20
# a value that is not valid UTF-8 is removed too
export MISE_BINARY_VALUE_VERSION=$'\xff'

mise shell --unset --all
assert_fail "printenv MISE_DUMMY_VERSION"
assert_fail "printenv MISE_TINY_VERSION"
assert_fail "printenv MISE_NODEJS_VERSION"
assert_fail "printenv MISE_BINARY_VALUE_VERSION"

# --all is only meaningful with --unset and cannot be combined with tools
assert_fail_contains "mise shell --all" "--all can only be used with --unset"
assert_fail "mise shell --unset --all tiny"
assert_fail "mise shell --unset"
