#!/usr/bin/env bash

# Test that environment-specific configs get the `env` field in lockfile
# When MISE_ENV=test, tools from mise.test.toml get env=["test"] in the lockfile

export MISE_LOCKFILE=1

# Create env-specific config only (to avoid override complexity)
cat >mise.test.toml <<'EOF'
[tools]
tiny = "2"
EOF

# Create lockfile
touch mise.lock

# Install version
assert "mise install tiny@2.1.0"

# With MISE_ENV=test, use the test config
# Note: Must pass MISE_ENV in the command itself since assert uses bash -c
assert "MISE_ENV=test mise use tiny@2"

# Check lockfile has env field for test-specific entry
assert_contains "cat mise.lock" 'env = ["test"]'
assert_contains "cat mise.lock" 'version = "2.1.0"'
assert_contains "cat mise.lock" '[[tools.tiny]]'
