Skip to content

Commit

Permalink
Merge pull request #255 from traylenator/accept
Browse files Browse the repository at this point in the history
Addition of Trivial Acceptance Tests
  • Loading branch information
traylenator authored Feb 21, 2022
2 parents a291dd9 + 4160b6e commit 01a7915
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,33 @@ jobs:
- name: Run tests
run: bundle exec rake parallel_spec

acceptance:
needs: setup_matrix
runs-on: ubuntu-latest
env:
BUNDLE_WITHOUT: development:test:release
strategy:
fail-fast: false
matrix:
include: ${{fromJson(needs.setup_matrix.outputs.github_action_test_matrix)}}
name: ${{ matrix.puppet.name }} - ${{ matrix.setfile.name }}
steps:
- uses: actions/checkout@v2
- name: Setup ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0'
bundler-cache: true
- name: Run tests
run: bundle exec rake beaker
env:
BEAKER_PUPPET_COLLECTION: ${{ matrix.puppet.collection }}
BEAKER_setfile: ${{ matrix.setfile.value }}

tests:
needs:
- unit
- acceptance
runs-on: ubuntu-latest
name: Test suite
steps:
Expand Down
4 changes: 4 additions & 0 deletions .sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@
enabled_lint_checks:
- parameter_documentation
- parameter_types

spec/spec_helper_acceptance.rb:
unmanaged: false

13 changes: 13 additions & 0 deletions spec/acceptance/default_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

require 'spec_helper_acceptance'

describe 'systemd' do
it_behaves_like 'an idempotent resource' do
let(:manifest) do
<<-PUPPET
include systemd
PUPPET
end
end
end
26 changes: 26 additions & 0 deletions spec/acceptance/resolved_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# frozen_string_literal: true

require 'spec_helper_acceptance'

describe 'systemd' do
context 'configure systemd resolved' do
it 'works idempotently with no errors' do
pp = <<-PUPPET
class{'systemd':
manage_resolved => true,
manage_resolv_conf => #{default[:hypervisor] != 'docker'},
}
PUPPET
apply_manifest(pp, catch_failures: true)
# RedHat 9 and newer installs package first run before fact $facts['internal_services'] is set
apply_manifest(pp, catch_failures: true) if Gem::Version.new(fact('os.release.major')) >= Gem::Version.new('9') && (fact('os.family') == 'RedHat')
apply_manifest(pp, catch_changes: true)
end

# RedHat 7 does not have systemd-resolved available at all.
describe service('systemd-resolved'), unless: (fact('os.release.major') == '7' and fact('os.family') == 'RedHat') do
it { is_expected.to be_running }
it { is_expected.to be_enabled }
end
end
end
10 changes: 10 additions & 0 deletions spec/spec_helper_acceptance.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

# Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/

require 'voxpupuli/acceptance/spec_helper_acceptance'

configure_beaker

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

0 comments on commit 01a7915

Please sign in to comment.