#!/usr/bin/env bash

# `mise lock` fails closed for an http platform it can't resolve: a platform with
# no URL is reported as skipped (and not written), rather than being miscounted
# as a successful entry while writing nothing. Mirrors test_github_matching_lock
# for the http backend.

export MISE_LOCKFILE=1

cat <<EOF >mise.toml
[tools."http:lockskip-test"]
version = "1.0.0"

[tools."http:lockskip-test".platforms.linux-x64]
url = "https://example.com/lockskip-{{ version }}-linux.tar.gz"
EOF

touch mise.lock

# linux-x64 has a URL (a url-only entry is written); macos-arm64 has none.
output="$(mise lock --platform linux-x64,macos-arm64)"

# The unresolvable platform is reported as skipped, not as a success.
assert_contains "echo '$output'" "1 skipped"

# The resolvable platform is written; the skipped one is not.
assert_contains "cat mise.lock" "platforms.linux-x64"
assert_not_contains "cat mise.lock" "macos-arm64"
