~charles/dotfiles

dotfiles/utils/query-webpage/test.sh -rwxr-xr-x 935 bytes
171c95a2Charles Daniels ztag: include tags in output 2 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/sh

set -o pipefail
set -u

cd "$(dirname "$0")"

timestamp() {
	date -u +"%Y-%m-%dT%H:%M:%SZ"
}

printf 'ts="%s" util=zettle msg="beginning tests for zettle"\n' "$(timestamp)"

FAILED=0
RES1="$(python3 query-webpage --url "file://$(realpath ./sample.html)" -q '//a[@href = "talks.html"]' -e)"
if [ "$RES1" = "Talks" ] ; then
	printf 'ts="%s" test=1 util=zettle status=pass\n' "$(timestamp)"
else
	printf 'ts="%s" test=1 util=zettle status=fail\n' "$(timestamp)"
	FAILED=$(expr $FAILED + 1)
fi


RES2="$(python3 query-webpage --url "file://$(realpath ./sample.html)"  -q '//h1' --extract_attribute class)"
if [ "$RES2" = "gemdown-heading" ] ; then
	printf 'ts="%s" test=2 util=zettle status=pass\n' "$(timestamp)"
else
	printf 'ts="%s" test=2 util=zettle status=fail\n' "$(timestamp)"
	FAILED=$(expr $FAILED + 1)
fi

printf 'ts="%s" util=zettle failed=%d msg="finished tests for zettle"\n' "$(timestamp)" "$FAILED"
exit $FAILED