github.com/turbot/steampipe@v1.7.0-rc.0.0.20240517123944-7cef272d4458/tests/acceptance/test_files/dynamic_schema.bats (about) 1 load "$LIB_BATS_ASSERT/load.bash" 2 load "$LIB_BATS_SUPPORT/load.bash" 3 4 # all tests are skipped - https://github.com/turbot/steampipe/issues/3742 5 6 @test "dynamic schema - add csv and query" { 7 skip "currently does not pass due to bug - https://github.com/turbot/steampipe/issues/3743" 8 9 # copy the csv file from csv source folder 10 cp $SRC_DATA_DIR/csv/a.csv $FILE_PATH/test_data/mods/csv_plugin_test/a.csv 11 12 # run the query and verify - should pass 13 run steampipe query "select * from csv1.a" 14 assert_success 15 } 16 17 @test "dynamic schema - add another column to csv and query the new column" { 18 skip "currently does not pass due to bug - https://github.com/turbot/steampipe/issues/3743" 19 # run the query and verify - should pass 20 run steampipe query "select * from csv1.a" 21 assert_success 22 23 # remove the a.csv file 24 rm -f $FILE_PATH/test_data/mods/csv_plugin_test/a.csv 25 26 # copy the csv file with extra column from csv source folder and give the same name(a.csv) 27 cp $SRC_DATA_DIR/csv/a_extra_col.csv $FILE_PATH/test_data/mods/csv_plugin_test/a.csv 28 29 # query the extra column and verify - should pass 30 run steampipe query 'select "column_D" from csv1.a' 31 assert_success 32 } 33 34 @test "dynamic schema - remove the csv with extra column and query (should fail)" { 35 skip "currently does not pass due to bug - https://github.com/turbot/steampipe/issues/3743" 36 # query the extra column and verify - should pass 37 run steampipe query 'select "column_D" from csv1.a' 38 assert_success 39 40 # remove the a.csv file with extra column and copy the old one again 41 rm -f $FILE_PATH/test_data/mods/csv_plugin_test/a.csv 42 cp $SRC_DATA_DIR/csv/a.csv $FILE_PATH/test_data/mods/csv_plugin_test/a.csv 43 44 # query the extra column and verify - should fail 45 run steampipe query 'select "column_D" from csv1.a' 46 assert_output --partial 'does not exist' 47 48 rm -f $FILE_PATH/test_data/mods/csv_plugin_test/a.csv 49 } 50 51 @test "dynamic schema - remove csv and query (should fail)" { 52 skip "currently does not pass due to bug - https://github.com/turbot/steampipe/issues/3743" 53 # copy the csv file from csv source folder 54 cp $SRC_DATA_DIR/csv/b.csv $FILE_PATH/test_data/mods/csv_plugin_test/b.csv 55 56 # run the query and verify - should pass 57 run steampipe query "select * from csv1.b" 58 assert_success 59 60 # remove the b.csv file 61 rm -f $FILE_PATH/test_data/mods/csv_plugin_test/b.csv 62 63 # run the query and verify - should fail 64 run steampipe query "select * from csv1.b" 65 assert_output --partial 'does not exist' 66 67 rm -f $FILE_PATH/test_data/mods/csv_plugin_test/b.csv 68 } 69 70 function teardown_file() { 71 # list running processes 72 ps -ef | grep steampipe 73 74 # check if any processes are running 75 num=$(ps aux | grep steampipe | grep -v bats | grep -v grep | grep -v tests/acceptance | wc -l | tr -d ' ') 76 assert_equal $num 0 77 } 78 79 80 function setup() { 81 # install csv plugin 82 run steampipe plugin install csv 83 84 cd $SRC_DATA_DIR 85 # appending the csv_plugin_test path 86 full_path="${FILE_PATH}/test_data/mods/csv_plugin_test/*.csv" 87 echo "${full_path}" 88 89 # escaping the slashes(/) 90 b=$(echo -e "${full_path}" | sed -e 's/\//\\\//g') 91 echo -e $b 92 93 # reading each line from the config template and storing in a file 94 while IFS= read -r line 95 do 96 echo "$line" >> output.spc 97 done < "csv_template.spc" 98 99 # replace the config file template with required path 100 sed -i -e "s/abc/${b}/g" 'output.spc' 101 102 # copy the new connection config 103 cp output.spc $STEAMPIPE_INSTALL_DIR/config/csv1.spc 104 } 105 106 function teardown() { 107 # remove the files created as part of these tests 108 rm -f $STEAMPIPE_INSTALL_DIR/config/csv*.spc 109 rm -f output.* 110 } 111 112 function setup_file() { 113 export STEAMPIPE_SYNC_REFRESH=true 114 }