From fc157a49a68c075bb8ebce30e5a57093a8201e9a Mon Sep 17 00:00:00 2001 From: Niall Crowe Date: Tue, 28 Nov 2023 09:16:52 +0000 Subject: [PATCH] test coverage for dotnet-monitor (#318) Adding test coverage for the diagnostic tool 'dotnet-monitor'. --- dotnet-monitor-works/test.json | 11 ++++++++ dotnet-monitor-works/test.sh | 48 ++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 dotnet-monitor-works/test.json create mode 100755 dotnet-monitor-works/test.sh diff --git a/dotnet-monitor-works/test.json b/dotnet-monitor-works/test.json new file mode 100644 index 0000000..7d9cf1b --- /dev/null +++ b/dotnet-monitor-works/test.json @@ -0,0 +1,11 @@ +{ + "name": "dotnet-monitor-works", + "enabled": true, + "requireSdk": true, + "version": "6.0", + "versionSpecific": false, + "type": "bash", + "cleanup": false, + "skipWhen": [ + ] +} diff --git a/dotnet-monitor-works/test.sh b/dotnet-monitor-works/test.sh new file mode 100755 index 0000000..c135590 --- /dev/null +++ b/dotnet-monitor-works/test.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash + +set -euo pipefail +set -x +IFS=$'\n\t' + +IFS='.-' read -ra VERSION_SPLIT <<< "$1" +dotnet tool update -g dotnet-monitor --version "${VERSION_SPLIT[0]}.*-*" + +export PATH="$HOME/.dotnet/tools:$PATH" + +dotnet-monitor collect --no-auth & +sleep 5 +indexhttps=$(wget --no-check-certificate -O https.html https://127.0.0.1:52323/info) + +https=$(cat https.html) + +if [[ $https == *"version"* ]]; then + sleep 5 + echo "collect - OK" +else + sleep 5 + pkill dotnet-monitor + rm "https.html" + echo "collect - FAIL" + exit 1 +fi + +pkill dotnet-monitor +rm "https.html" + +config=$(dotnet-monitor config show) +if [[ $config == *"Metrics"* ]]; then + echo "config show - OK" +else + echo "config show - FAIL" + pkill dotnet-monitor + exit 1 +fi + +authkey=$(dotnet-monitor generatekey) +if [[ $authkey == *"Authorization: Bearer"* ]]; then + echo "generatekey - OK" +else + echo "generatekey - FAIL" + pkill dotnet-monitor + exit 1 +fi \ No newline at end of file