github.com/turbot/steampipe@v1.7.0-rc.0.0.20240517123944-7cef272d4458/tests/acceptance/test_files/dashboard.bats (about) 1 load "$LIB_BATS_ASSERT/load.bash" 2 load "$LIB_BATS_SUPPORT/load.bash" 3 4 @test "simple dashboard test" { 5 # run a dashboard and shapshot the output 6 run steampipe dashboard dashboard.sibling_containers_report --export test.sps --output none --mod-location "$FILE_PATH/test_data/mods/dashboard_sibling_containers" 7 8 # get the patch diff between the two snapshots 9 run jd -f patch $SNAPSHOTS_DIR/expected_sps_sibling_containers_report.json test.sps 10 11 # run the script to evaluate the patch 12 # returns nothing if there is no diff(except start_time, end_time & search_path) 13 diff=$($FILE_PATH/json_patch.sh $output) 14 echo $diff 15 rm -f test.sps 16 17 # check if there is no diff returned by the script 18 assert_equal "$diff" "" 19 } 20 21 @test "dashboard with 'with' blocks" { 22 # run a dashboard and shapshot the output 23 run steampipe dashboard dashboard.testing_with_blocks --export test.sps --output none --mod-location "$FILE_PATH/test_data/mods/dashboard_withs" 24 25 # sort the panels data by 'name' using jq sort_by(for ease in comparison) 26 cat test.sps | jq '.panels."dashbaord_withs.graph.with_testing".data.columns|=sort_by(.name)' > test2.json 27 28 # get the patch diff between the two snapshots 29 run jd -f patch $SNAPSHOTS_DIR/expected_sps_many_withs_dashboard.json test2.json 30 31 # run the script to evaluate the patch 32 # returns nothing if there is no diff(except start_time, end_time & search_path) 33 diff=$($FILE_PATH/json_patch.sh $output) 34 echo $diff 35 rm -f test.sps 36 rm -f test2.json 37 38 # check if there is no diff returned by the script 39 assert_equal "$diff" "" 40 } 41 42 @test "dashboard with 'text' blocks" { 43 # run a dashboard and shapshot the output 44 run steampipe dashboard dashboard.testing_text_blocks --export test.sps --output none --mod-location "$FILE_PATH/test_data/mods/dashboard_texts" 45 46 # get the patch diff between the two snapshots 47 run jd -f patch $SNAPSHOTS_DIR/expected_sps_testing_text_blocks_dashboard.json test.sps 48 49 # run the script to evaluate the patch 50 # returns nothing if there is no diff(except start_time, end_time & search_path) 51 diff=$($FILE_PATH/json_patch.sh $output) 52 echo $diff 53 rm -f test.sps 54 55 # check if there is no diff returned by the script 56 assert_equal "$diff" "" 57 } 58 59 @test "dashboard with 'card' blocks" { 60 # run a dashboard and shapshot the output 61 run steampipe dashboard dashboard.testing_card_blocks --export test.sps --output none --mod-location "$FILE_PATH/test_data/mods/dashboard_cards" 62 63 # get the patch diff between the two snapshots 64 run jd -f patch $SNAPSHOTS_DIR/expected_sps_testing_card_blocks_dashboard.json test.sps 65 66 67 # run the script to evaluate the patch 68 # returns nothing if there is no diff(except start_time, end_time & search_path) 69 diff=$($FILE_PATH/json_patch.sh $output) 70 echo $diff 71 rm -f test.sps 72 73 # check if there is no diff returned by the script 74 assert_equal "$diff" "" 75 } 76 77 @test "dashboard with node and edge blocks" { 78 # run a dashboard and shapshot the output 79 run steampipe dashboard dashboard.testing_nodes_and_edges --export test.sps --output none --mod-location "$FILE_PATH/test_data/mods/dashboard_graphs" 80 81 # sort the panels data by 'name' using jq sort_by(for ease in comparison) 82 cat test.sps | jq '.panels."dashboard_graphs.graph.node_and_edge_testing".data.columns|=sort_by(.name)' > test2.json 83 84 # get the patch diff between the two snapshots 85 run jd -f patch $SNAPSHOTS_DIR/expected_sps_testing_nodes_and_edges_dashboard.json test2.json 86 87 # run the script to evaluate the patch 88 # returns nothing if there is no diff(except start_time, end_time & search_path) 89 diff=$($FILE_PATH/json_patch.sh $output) 90 echo $diff 91 rm -f test.sps 92 rm -f test2.json 93 94 # check if there is no diff returned by the script 95 assert_equal "$diff" "" 96 } 97 98 @test "dashboard with 'input' and test --dashboard-input arg" { 99 # run a dashboard and shapshot the output 100 run steampipe dashboard dashboard.testing_dashboard_inputs --export test.sps --output none --mod-location "$FILE_PATH/test_data/mods/dashboard_inputs" --dashboard-input new_input=test 101 102 # get the patch diff between the two snapshots 103 run jd -f patch $SNAPSHOTS_DIR/expected_sps_testing_dashboard_inputs.json test.sps 104 105 # run the script to evaluate the patch 106 # returns nothing if there is no diff(except start_time, end_time & search_path) 107 diff=$($FILE_PATH/json_patch.sh $output) 108 echo $diff 109 rm -f test.sps 110 111 # check if there is no diff returned by the script 112 assert_equal "$diff" "" 113 } 114 115 @test "dashboard input with base" { 116 # run a dashboard and shapshot the output 117 run steampipe dashboard dashboard.resource_details --export test.sps --output none --mod-location "$FILE_PATH/test_data/dashboard_inputs_with_base" 118 119 # get the patch diff between the two snapshots 120 run jd -f patch $SNAPSHOTS_DIR/expected_sps_testing_dashboard_inputs_with_base.json test.sps 121 echo $output 122 123 # run the script to evaluate the patch 124 # returns nothing if there is no diff(except start_time, end_time & search_path) 125 diff=$($FILE_PATH/json_patch.sh $output) 126 echo $diff 127 rm -f test.sps 128 129 # check if there is no diff returned by the script 130 assert_equal "$diff" "" 131 } 132 133 function teardown_file() { 134 # list running processes 135 ps -ef | grep steampipe 136 137 # check if any processes are running 138 num=$(ps aux | grep steampipe | grep -v bats | grep -v grep | grep -v tests/acceptance | wc -l | tr -d ' ') 139 assert_equal $num 0 140 }