From bf619aaf12080a14be298f4c7f364d80a52b46a3 Mon Sep 17 00:00:00 2001 From: Tomasz Pluskiewicz Date: Tue, 28 Nov 2023 16:23:58 +0100 Subject: [PATCH] test: use node to shorten --- .github/workflows/test.yaml | 2 ++ test/profiles.sh | 37 +++++++------------------------------ test/shorten-report.js | 27 +++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 30 deletions(-) create mode 100755 test/shorten-report.js diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 037d7bd..7a76297 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -8,5 +8,7 @@ jobs: steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v3 + with: + node-version: 20 - run: npm ci - run: bash ./test/profiles.sh diff --git a/test/profiles.sh b/test/profiles.sh index 5a58289..fbe45be 100755 --- a/test/profiles.sh +++ b/test/profiles.sh @@ -1,45 +1,22 @@ #!/usr/bin/env bash -set -x - SCRIPT_PATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" FAILED=0 -SHACL_PLAYGROUND_URL="https://shacl-playground.zazuko.com/" -SHORTENER="https://s.zazuko.com/api/v1/shorten/" - -function urlencode() { - set +x - local string="${1}" - local strlen=${#string} - local encoded="" - local pos c o - - for (( pos=0 ; pos /dev/null 2>&1; then + { + barnard59 cube check-metadata --profile validation/profile-opendataswiss.ttl > /dev/null 2>&1 + success=$? + } < "$file" + + if [ $success -ne 0 ] ; then reportFailure "$(cat validation/profile-opendataswiss.ttl)" "$(cat "$file")" FAILED=1 fi diff --git a/test/shorten-report.js b/test/shorten-report.js new file mode 100755 index 0000000..ef1a7b6 --- /dev/null +++ b/test/shorten-report.js @@ -0,0 +1,27 @@ +#!/usr/bin/env node + +const SHACL_PLAYGROUND_URL = 'https://shacl-playground.zazuko.com/' +const SHORTENER = 'https://s.zazuko.com/api/v1/shorten/' + +;(async function () { + const params = new URLSearchParams({ + shapesGraph: process.argv[2], + dataGraph: process.argv[3], + dataGraphFormat: 'text/turtle', + page: 2 + }) + + const playgroundUrl = new URL(SHACL_PLAYGROUND_URL) + playgroundUrl.hash = params.toString() + + const response = await fetch(SHORTENER, { + method: 'POST', + headers: { + 'Content-Type': 'application/x-www-form-urlencoded' + }, + body: new URLSearchParams({ + url: playgroundUrl.toString() + }) + }) + process.stdout.write(await response.text()) +})()