#!/usr/bin/env bash

# `mise lock` creates the entry that `tool_config.locked` demands, so a tool
# missing from the lockfile must not stop it in the default generate mode.
export MISE_LOCKFILE=1
export MISE_LOCKFILE_MODE=generate
mise plugin install tiny

cat <<'EOT' >mise.toml
[tool_config]
locked = true

[tools]
tiny = "1.0.0"
EOT

assert_fail_contains "mise install --dry-run 2>&1" "is not in the lockfile"
assert "mise lock tiny"
assert_contains "cat mise.lock" 'version = "1.0.0"'

# Task tools are resolved through a separate path and need the same fallback.
rm mise.lock
cat <<'EOT' >mise.toml
[tool_config]
locked = true

[tasks.hello]
run = "echo hi"
tools = { tiny = "1.0.0" }
EOT
assert "mise lock"
assert_contains "cat mise.lock" 'version = "1.0.0"'
