#!/bin/bash

# This test verifies that any configured R package repositores are
# reachable from within the sandbox. This might fail if there
# is a misconfiguration of networking, proxies, SSL certificates,
# etc.

# This test isn't auto-detected; it is scheduled in selftest/r_build.go
# for each configured RPackageRepository.

# Arguments:
# $1: repository name 
# $2: repository URL

# Both come from the Connect configuration item RPackageRepository, e.g.

# [RPackageRepository "MyCRAN"]
# URL="https://mycran.example.com"

# $1 == "MyCRAN"
# $2 == "https://mycran.example.com"

set -euo pipefail
execute() { echo; echo "\$ $*"; "$@"; }

CURL="curl -Lsv -m 10 --retry 0 -o /dev/null"

# shellcheck disable=SC2086
execute $CURL "$2"
