From 8030e8ed9c19fc218fa96b7f57f660eb8398f44c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20=C3=96hrstr=C3=B6m?= Date: Mon, 2 Jan 2023 23:59:16 +0100 Subject: [PATCH] Fix test. --- simulations/simulation_dll_tpl_diff.txt | 2 +- tests/test_match_dll_and_tpl_id.sh | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/simulations/simulation_dll_tpl_diff.txt b/simulations/simulation_dll_tpl_diff.txt index cb071ef..b9e4e83 100644 --- a/simulations/simulation_dll_tpl_diff.txt +++ b/simulations/simulation_dll_tpl_diff.txt @@ -1,2 +1,2 @@ -telegram=|6644242381818181640E7246564656A51170071F0050052F2F|15257A616F14139172137DAE3A0C000000008C2013917213000B3B0000000B26784601025AF5000266EF00046D1B08B7214C1338861200CC101300000000CC201338861200426C9F2C42EC7EBF2C| +telegram=|6644242381818181640E7246564656A51170071F0050052F2F_15257A616F14139172137DAE3A0C000000008C2013917213000B3B0000000B26784601025AF5000266EF00046D1B08B7214C1338861200CC101300000000CC201338861200426C9F2C42EC7EBF2C| {"media":"water","meter":"hydrus","name":"Vatten","id":"56465646","operating_time_h":14678,"meter_datetime":"2021-01-23 08:27","flow_temperature_c":24.5,"external_temperature_c":23.9,"status":"OK","total_tariff2_m3":137.291,"total_tariff1_at_date_m3":0,"total_tariff2_at_date_m3":128.638,"flow_m3h":0,"total_at_date_m3":128.638,"at_date":"2020-12-31","timestamp":"1111-11-11T11:11:11Z"} diff --git a/tests/test_match_dll_and_tpl_id.sh b/tests/test_match_dll_and_tpl_id.sh index 276372d..c738182 100755 --- a/tests/test_match_dll_and_tpl_id.sh +++ b/tests/test_match_dll_and_tpl_id.sh @@ -9,19 +9,24 @@ TEST=testoutput TESTNAME="Test match on dll id" TESTRESULT="ERROR" -cat simulations/simulation_dll_tpl_diff.txt | grep '^{' > $TEST/test_expected.txt +cat simulations/simulation_dll_tpl_diff.txt | grep '^{' | jq --sort-keys . > $TEST/test_expected.txt $PROG --format=json simulations/simulation_dll_tpl_diff.txt \ Vatten hydrus 81818181 NOKEY \ > $TEST/test_output.txt 2> $TEST/test_stderr.txt if [ "$?" = "0" ] then - cat $TEST/test_output.txt | sed 's/"timestamp":"....-..-..T..:..:..Z"/"timestamp":"1111-11-11T11:11:11Z"/' > $TEST/test_responses.txt + cat $TEST/test_output.txt | jq --sort-keys . | sed 's/"timestamp": "....-..-..T..:..:..Z"/"timestamp": "1111-11-11T11:11:11Z"/' > $TEST/test_responses.txt diff $TEST/test_expected.txt $TEST/test_responses.txt if [ "$?" = "0" ] then echo OK: $TESTNAME TESTRESULT="OK" + else + if [ "$USE_MELD" = "true" ] + then + meld $TEST/test_expected.txt $TEST/test_responses.txt + fi fi else echo "wmbusmeters returned error code: $?" @@ -39,19 +44,24 @@ fi TESTNAME="Test match on tpl id" TESTRESULT="ERROR" -cat simulations/simulation_dll_tpl_diff.txt | grep '^{' > $TEST/test_expected.txt +cat simulations/simulation_dll_tpl_diff.txt | grep '^{' | jq --sort-keys . > $TEST/test_expected.txt $PROG --format=json simulations/simulation_dll_tpl_diff.txt \ Vatten hydrus 56465646 NOKEY \ > $TEST/test_output.txt 2> $TEST/test_stderr.txt if [ "$?" = "0" ] then - cat $TEST/test_output.txt | sed 's/"timestamp":"....-..-..T..:..:..Z"/"timestamp":"1111-11-11T11:11:11Z"/' > $TEST/test_responses.txt + cat $TEST/test_output.txt | jq --sort-keys . | sed 's/"timestamp": "....-..-..T..:..:..Z"/"timestamp": "1111-11-11T11:11:11Z"/' > $TEST/test_responses.txt diff $TEST/test_expected.txt $TEST/test_responses.txt if [ "$?" = "0" ] then echo OK: $TESTNAME TESTRESULT="OK" + else + if [ "$USE_MELD" = "true" ] + then + meld $TEST/test_expected.txt $TEST/test_responses.txt + fi fi else echo "wmbusmeters returned error code: $?"