github.com/turbot/steampipe@v1.7.0-rc.0.0.20240517123944-7cef272d4458/tests/acceptance/test_files/mod_install.bats (about) 1 load "$LIB_BATS_ASSERT/load.bash" 2 load "$LIB_BATS_SUPPORT/load.bash" 3 4 @test "list with no mods installed" { 5 run steampipe mod list 6 assert_output --partial 'No mods installed.' 7 } 8 9 @test "install latest(plugin requirement not satisfied)" { 10 run steampipe mod install github.com/turbot/steampipe-mod-aws-compliance 11 assert_output --partial "dependency failed to install" 12 } 13 14 @test "install latest(--force)" { 15 run steampipe mod install github.com/turbot/steampipe-mod-aws-compliance --force 16 assert_output --partial 'Installed 1 mod: 17 18 local 19 └── github.com/turbot/steampipe-mod-aws-compliance' 20 # need the check the version from mod.sp file as well 21 } 22 23 @test "install latest and then run install" { 24 steampipe mod install github.com/turbot/steampipe-mod-aws-compliance --force 25 run steampipe mod install 26 assert_output --partial 'All mods are up to date' 27 } 28 29 @test "install mod and list" { 30 steampipe mod install github.com/turbot/steampipe-mod-aws-compliance@0.10 --force 31 run steampipe mod list 32 assert_output --partial ' 33 local 34 └── github.com/turbot/steampipe-mod-aws-compliance@v0.10.0' 35 } 36 37 @test "install old version when latest already installed" { 38 steampipe mod install github.com/turbot/steampipe-mod-aws-compliance --force 39 run steampipe mod install github.com/turbot/steampipe-mod-aws-compliance@0.1 40 assert_output --partial ' 41 Downgraded 1 mod: 42 43 local 44 └── github.com/turbot/steampipe-mod-aws-compliance@v0.1.0' 45 } 46 47 @test "install mod version, remove .steampipe folder and then run install" { 48 # install particular mod version, remove .steampipe folder and run mod install 49 steampipe mod install github.com/turbot/steampipe-mod-aws-compliance@0.1 --force 50 rm -rf .steampipe 51 run steampipe mod install 52 53 # should install the same cached version 54 # better message 55 assert_output --partial ' 56 Installed 1 mod: 57 58 local 59 └── github.com/turbot/steampipe-mod-aws-compliance@v0.1.0' 60 } 61 62 @test "install mod version, remove .cache file and then run install" { 63 # install particular mod version, remove .mod.cache.json file and run mod install 64 steampipe mod install github.com/turbot/steampipe-mod-aws-compliance@0.1 --force 65 rm -rf .mod.cache.json 66 run steampipe mod install 67 68 # should install the same cached version 69 # better message 70 assert_output --partial ' 71 Installed 1 mod: 72 73 local 74 └── github.com/turbot/steampipe-mod-aws-compliance@v0.1.0' 75 } 76 77 @test "install mod version should fail, since dependant mod has a requirement of different steampipe CLI version" { 78 run steampipe mod install github.com/pskrbasu/steampipe-mod-m4 79 assert_output --partial 'does not satisfy mod.m4 which requires version 10.99.99' 80 } 81 82 @test "install a mod with protocol in url" { 83 skip 84 run steampipe mod install https://github.com/turbot/steampipe-mod-hackernews-insights@0.4.0 85 # should install with the protocol in the url prefix 86 assert_output --partial ' 87 Installed 1 mod: 88 89 local 90 └── github.com/turbot/steampipe-mod-hackernews-insights@v0.4.0' 91 } 92 93 # Installed 4 mods: 94 95 # local 96 # └── github.com/pskrbasu/steampipe-mod-top-level@v3.0.0 97 # ├── github.com/pskrbasu/steampipe-mod-dependency-1@v4.0.0 98 # └── github.com/pskrbasu/steampipe-mod-dependency-2@v3.0.0 99 # └── github.com/pskrbasu/steampipe-mod-dependency-1@v3.0.0 100 @test "complex mod dependency resolution - test tree structure" { 101 run steampipe mod install github.com/pskrbasu/steampipe-mod-top-level 102 # test the tree structure output 103 assert_output --partial ' 104 Installed 4 mods: 105 106 local 107 └── github.com/pskrbasu/steampipe-mod-top-level@v3.0.0 108 ├── github.com/pskrbasu/steampipe-mod-dependency-1@v4.0.0 109 └── github.com/pskrbasu/steampipe-mod-dependency-2@v3.0.0 110 └── github.com/pskrbasu/steampipe-mod-dependency-1@v3.0.0' 111 } 112 113 @test "complex mod dependency resolution - test benchmark and controls resolution 1" { 114 steampipe mod install github.com/pskrbasu/steampipe-mod-top-level 115 116 run steampipe check top_level.benchmark.bm_version_dependency_mod_1 --output csv 117 # check the output - benchmark should run the control and query from dependency mod 1 which will 118 # have the output: 119 # +--------+----------+--------+ 120 # | reason | resource | status | 121 # +--------+----------+--------+ 122 # | 4 | 4 | alarm | 123 # +--------+----------+--------+ 124 assert_output --partial 'group_id,title,description,control_id,control_title,control_description,reason,resource,status,severity 125 top_level.benchmark.bm_version_dependency_mod_1,Benchmark version dependency mod 1,,dependency_1.control.version,,,4,4,alarm,' 126 } 127 128 @test "complex mod dependency resolution - test benchmark and controls resolution 2" { 129 steampipe mod install github.com/pskrbasu/steampipe-mod-top-level 130 131 run steampipe check top_level.benchmark.bm_version_dependency_mod_2 --output csv 132 # check the output - benchmark should run the control and query from dependency mod 2 which will 133 # have the output: 134 # +--------+----------+--------+ 135 # | reason | resource | status | 136 # +--------+----------+--------+ 137 # | 3 | 3 | ok | 138 # +--------+----------+--------+ 139 assert_output --partial 'group_id,title,description,control_id,control_title,control_description,reason,resource,status,severity 140 top_level.benchmark.bm_version_dependency_mod_2,Benchmark version dependency mod 2,,dependency_2.control.version,,,3,3,ok,' 141 } 142 143 function teardown_file() { 144 # list running processes 145 ps -ef | grep steampipe 146 147 # check if any processes are running 148 num=$(ps aux | grep steampipe | grep -v bats | grep -v grep | grep -v tests/acceptance | wc -l | tr -d ' ') 149 assert_equal $num 0 150 } 151 152 function teardown() { 153 rm -rf .steampipe/ 154 rm -rf .mod.cache.json 155 rm -rf mod.sp 156 } 157 158 function setup() { 159 cd $FILE_PATH/test_data/mods/mod_install 160 }