#!/usr/bin/env bash

export MISE_LOCKFILE=1

detect_platform
PLATFORM="$MISE_PLATFORM"

# Expected URL for ripgrep based on platform
case "$MISE_PLATFORM" in
  macos-arm64)
    URL="https://github.com/BurntSushi/ripgrep/releases/download/14.1.1/ripgrep-14.1.1-aarch64-apple-darwin.tar.gz"
    ;;
  macos-x64)
    URL="https://github.com/BurntSushi/ripgrep/releases/download/14.1.1/ripgrep-14.1.1-x86_64-apple-darwin.tar.gz"
    ;;
  linux-arm64)
    URL="https://github.com/BurntSushi/ripgrep/releases/download/14.1.1/ripgrep-14.1.1-aarch64-unknown-linux-musl.tar.gz"
    ;;
  linux-x64)
    URL="https://github.com/BurntSushi/ripgrep/releases/download/14.1.1/ripgrep-14.1.1-x86_64-unknown-linux-musl.tar.gz"
    ;;
  *)
    URL=""
    ;;
esac

# Test that aqua backend stores URLs in lockfile
rm -rf mise.lock

touch mise.lock

mise use ripgrep@14.1.1

assert_contains "cat mise.lock" "\"platforms.$PLATFORM\""
assert_contains "cat mise.lock" "url = \"$URL\""

echo "Lockfile content:"
cat mise.lock

echo ""
echo "Aqua URL storage test passed!"
