Skip to content

Commit

Permalink
Add new way to test library functionality for decrement
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosmmatos committed Nov 18, 2022
1 parent 080fb92 commit 6db835e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
24 changes: 21 additions & 3 deletions test/cookbooks/test/recipes/install_api_decrement.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
client_id = ENV['FALCON_CLIENT_ID']
client_secret = ENV['FALCON_CLIENT_SECRET']
falcon_cloud = ENV['FALCON_CLOUD']
sensor_tmp_dir = '/tmp'

falcon_install 'falcon' do
client_id ENV['FALCON_CLIENT_ID']
client_secret ENV['FALCON_CLIENT_SECRET']
falcon_cloud ENV['FALCON_CLOUD']
client_id client_id
client_secret client_secret
falcon_cloud falcon_cloud
version_decrement 2
action :install
end

# Use the helpers library to get the version of the requested package
::Chef::DSL::Recipe.send(:include, ChefFalcon::Helpers)

sensor_info = sensor_download_info(client_id, client_secret, {
version_decrement: 2,
sensor_tmp_dir: sensor_tmp_dir,
falcon_cloud: falcon_cloud,
})

file "#{sensor_tmp_dir}/version" do
content sensor_info['version']
end

include_recipe 'test::common'
9 changes: 8 additions & 1 deletion test/integration/install_api_decrement/controls/default.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# Include common controls
include_controls 'common'

# TODO: Figure out how to get sensor version from API
# We want to ensure the package version installed matches the version we expect
# from the /tmp/version file
sensor_tmp_dir = '/tmp'
sensor_version_file = File.join(sensor_tmp_dir, 'version')

describe package('falcon-sensor') do
its('version') { should match file(sensor_version_file).content.strip }
end

0 comments on commit 6db835e

Please sign in to comment.