#!/usr/bin/env bash

export MISE_LOCKFILE=1
export MISE_EXPERIMENTAL=1

touch mise.lock
mise use tiny
cat <<EOF >mise.lock
[tools.tiny]
version = "1.0.0"
EOF
rm -rf "$MISE_DATA_DIR/installs/tiny"
mise install
assert "mise ls tiny --json --current | jq -r '.[0].requested_version'" "latest"
assert "mise ls tiny --json --current | jq -r '.[0].version'" "1.0.0"

# validates checksum
mise use gh@2.62.0
cat mise.lock
assert_contains "cat mise.lock" "[tools.gh.checksums]"
cat <<EOF >mise.lock
[tools.gh]
version = "2.62.0"
[tools.gh.checksums]
"gh_2.62.0_macOS_arm64.zip" = "sha512:0000000000"
"gh_2.62.0_windows_arm64.zip" = "sha512:0000000000"
"gh_2.62.0_linux_arm64.tar.gz" = "sha512:0000000000"
"gh_2.62.0_windows_amd64.zip" = "sha512:0000000000"
"gh_2.62.0_linux_amd64.tar.gz" = "sha512:0000000000"
EOF
assert_fail "mise i gh -f"
