github.com/turbot/steampipe@v1.7.0-rc.0.0.20240517123944-7cef272d4458/tests/acceptance/json_patch.sh (about) 1 #!/bin/bash -e 2 3 # This script accepts a patch format and evaluates the diffs if any. 4 patch_file=$1 5 6 patch_keys=$(echo $patch_file | jq -r '. | keys[]') 7 8 for i in $patch_keys; do 9 op=$(echo $patch_file | jq -r -c ".[${i}]" | jq -r ".op") 10 path=$(echo $patch_file | jq -r -c ".[${i}]" | jq -r ".path") 11 value=$(echo $patch_file | jq -r -c ".[${i}]" | jq -r ".value") 12 13 # ignore the diff of paths 'end_time', 'start_time' and 'schema_version', 14 # print the rest 15 if [[ $op != "test" ]] && [[ $path != "/end_time" ]] && [[ $path != "/start_time" ]] && [[ $path != "/schema_version" ]] && [[ $path != "/metadata"* ]]; then 16 if [[ $op == "remove" ]]; then 17 echo "key: $path" 18 echo "expected: $value" 19 else 20 echo "actual: $value" 21 fi 22 fi 23 done