Skip to content

Commit

Permalink
add spec tests with mock vault_version fact
Browse files Browse the repository at this point in the history
  • Loading branch information
C24-AK committed Jun 25, 2024
1 parent f5de2ba commit a850607
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
40 changes: 40 additions & 0 deletions spec/acceptance/class_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,46 @@ class { 'file_capability':
describe port(8200) do
it { is_expected.to be_listening.on('127.0.0.1').with('tcp') }
end

describe command('/usr/local/bin/vault version') do
its(:exit_status) { is_expected.to eq 0 }
its(:stdout) { is_expected.to match %r{Vault v1.12.0} }
end
end

context 'default parameters with vesion higher than fact' do
let(:manifest) do
<<-PUPPET
if $facts['os']['name'] == 'Archlinux' {
class { 'file_capability':
package_name => 'libcap',
}
} else {
include file_capability
}
package { 'unzip': ensure => present }
-> class { 'vault':
storage => {
file => {
path => '/tmp',
}
},
bin_dir => '/usr/local/bin',
install_method => 'archive',
version => '1.12.1',
require => Class['file_capability'],
}
PUPPET
end

it 'should not be idempotent and cause changes' do

Check failure on line 117 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Static validations

RSpec/ExampleWording: Do not use should when describing your tests. (https://rspec.rubystyle.guide/#should-in-example-docstrings, https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExampleWording)
apply_manifest(manifest, expect_changes: true)
end

Check failure on line 119 in spec/acceptance/class_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Static validations

Layout/TrailingWhitespace: Trailing whitespace detected. (https://rubystyle.guide#no-trailing-whitespace)

describe command('/usr/local/bin/vault version') do
its(:exit_status) { is_expected.to eq 0 }
its(:stdout) { is_expected.to match %r{Vault v1.12.1} }
end
end

context 'with package based setup' do
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper_acceptance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

require 'voxpupuli/acceptance/spec_helper_acceptance'

ENV['BEAKER_FACTER_VAULT_VERSION'] = '1.12.0'
configure_beaker(modules: :metadata)

Dir['./spec/support/acceptance/**/*.rb'].sort.each { |f| require f }

0 comments on commit a850607

Please sign in to comment.