#!/usr/bin/env bash

set -eo pipefail
source debian/tests/.tests.rc.d/init.sh

ChangeToAutopkgtestTmpFolder

LogInfo "Creating demo global.json file"
cat <<EOF >global.json
{
  "sdk": {
    "version": "$DOTNET_SDK_VERSION",
    "rollForward": "latestFeature"
  }
}
EOF

LogInfo "Testing if 'dotnet --info' shows path of global.json file"
path=$PWD/global.json
count=$(echo "$(dotnet --info)" | grep "$path" -nc)
if [[ "${count}" != "1" ]]; then
    LogErrorAndTerminate "The global.json file path was expected once in the 'dotnet --info' output. Actually found ${count} occurences." 
fi

LogInfo "Test Ok!"
