wmbusmeters/tests/test_conversions.sh

43 wiersze
1.3 KiB
Bash
Czysty Zwykły widok Historia

#!/bin/sh
2019-05-04 21:00:59 +00:00
PROG="$1"
2019-06-06 16:16:24 +00:00
rm -rf testoutput
2019-05-04 21:00:59 +00:00
mkdir -p testoutput
TEST=testoutput
TESTNAME="Test conversions of units using calculations"
2019-11-03 21:00:18 +00:00
TESTRESULT="ERROR"
cat simulations/simulation_conversionsadded.txt | grep '^{' | jq --sort-keys . > $TEST/test_expected.txt
$PROG --format=json --calculate_total_gj=total_kwh \
--calculate_current_gj=current_kwh \
--calculate_previous_gj=previous_kwh \
--calculate_external_temperature_f=external_temperature_c \
--calculate_flow_temperature_f=flow_temperature_c \
--calculate_target_l=target_m3 \
--calculate_total_l=total_m3 \
simulations/simulation_conversionsadded.txt \
Hettan vario451 58234965 "" \
2020-01-27 08:29:40 +00:00
MyTapWater multical21 76348799 "" \
2> $TEST/test_stderr.txt \
| jq --sort-keys . > $TEST/test_output.txt
2019-06-06 16:16:24 +00:00
2020-04-22 06:07:19 +00:00
if [ "$?" = "0" ]
2019-05-04 21:00:59 +00:00
then
cat $TEST/test_output.txt | sed 's/"timestamp": "....-..-..T..:..:..Z"/"timestamp": "1111-11-11T11:11:11Z"/' > $TEST/test_responses.txt
2019-05-04 21:00:59 +00:00
diff $TEST/test_expected.txt $TEST/test_responses.txt
2020-04-22 06:07:19 +00:00
if [ "$?" = "0" ]
2019-05-04 21:00:59 +00:00
then
2019-11-03 21:00:18 +00:00
echo "OK: $TESTNAME"
TESTRESULT="OK"
else
if [ "$USE_MELD" = "true" ]
then
meld $TEST/test_expected.txt $TEST/test_responses.txt
fi
2019-05-04 21:00:59 +00:00
fi
fi
2019-11-03 21:00:18 +00:00
if [ "$TESTRESULT" = "ERROR" ]; then echo ERROR: $TESTNAME; exit 1; fi