beaker_puppet_helpers 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe BeakerPuppetHelpers::InstallUtils do
6
+ describe '.install_puppet_release_repo_on' do
7
+ let(:host) { instance_double(Beaker::Host) }
8
+ let(:packaging_platform) { Beaker::Platform.new(platform) }
9
+
10
+ before { allow(host).to receive(:[]).with('packaging_platform').and_return(packaging_platform) }
11
+
12
+ context 'with default options' do
13
+ subject(:install_puppet_release_repo_on) { described_class.install_puppet_release_repo_on(host) }
14
+
15
+ context 'with EL 7 platform' do
16
+ let(:platform) { 'el-7-x86_64' }
17
+
18
+ it 'installs from the correct url' do
19
+ expect(host).to receive(:install_package).with('https://yum.puppet.com/puppet-release-el-7.noarch.rpm')
20
+
21
+ install_puppet_release_repo_on
22
+ end
23
+ end
24
+
25
+ context 'with Fedora 34 platform' do
26
+ let(:platform) { 'fedora-34-x86_64' }
27
+
28
+ it 'installs from the correct url' do
29
+ expect(host).to receive(:install_package).with('https://yum.puppet.com/puppet-release-fedora-34.noarch.rpm')
30
+
31
+ install_puppet_release_repo_on
32
+ end
33
+ end
34
+
35
+ context 'with SLES 15 platform' do
36
+ let(:platform) { 'sles-15-x86_64' }
37
+
38
+ it 'installs from the correct url and calls rpm --import' do
39
+ expect(host).to receive(:install_package).with('https://yum.puppet.com/puppet-release-sles-15.noarch.rpm')
40
+
41
+ expect(described_class).to receive(:wget_on).with(host, 'https://yum.puppet.com/RPM-GPG-KEY-puppet').and_yield('puppet.gpg').once
42
+ expect(Beaker::Command).to receive(:new).with("rpm --import 'puppet.gpg'").and_return("rpm --import 'puppet.gpg'").once
43
+ expect(host).to receive(:exec).with("rpm --import 'puppet.gpg'").once
44
+
45
+ expect(described_class).to receive(:wget_on).with(host, 'https://yum.puppet.com/RPM-GPG-KEY-puppet-20250406').and_yield('puppet-20250406.gpg').once
46
+ expect(Beaker::Command).to receive(:new).with("rpm --import 'puppet-20250406.gpg'").and_return("rpm --import 'puppet-20250406.gpg'").once
47
+ expect(host).to receive(:exec).with("rpm --import 'puppet-20250406.gpg'").once
48
+
49
+ install_puppet_release_repo_on
50
+ end
51
+ end
52
+
53
+ context 'with Debian 11 platform' do
54
+ let(:platform) { 'debian-11-x86_64' }
55
+
56
+ before { allow(host).to receive(:[]).with('platform').and_return(packaging_platform) }
57
+
58
+ it 'installs from the correct url and runs apt-get update' do
59
+ expect(described_class).to receive(:wget_on).with(host, 'https://apt.puppet.com/puppet-release-bullseye.deb').and_yield('filename.deb')
60
+ expect(host).to receive(:install_package).with('filename.deb')
61
+ expect(Beaker::Command).to receive(:new).with('apt-get update').and_return('apt-get update')
62
+ expect(host).to receive(:exec).with('apt-get update')
63
+ expect(host).to receive(:add_env_var).with('PATH', '/opt/puppetlabs/bin')
64
+
65
+ install_puppet_release_repo_on
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,101 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ class ClassMixedWithDSLInstallUtils
6
+ include Beaker::DSL::Patterns
7
+ include BeakerPuppetHelpers::ModuleUtils
8
+
9
+ def logger
10
+ @logger ||= RSpec::Mocks::Double.new('Beaker::Logger').as_null_object
11
+ end
12
+ end
13
+
14
+ describe BeakerPuppetHelpers::ModuleUtils do
15
+ subject(:dsl) { ClassMixedWithDSLInstallUtils.new }
16
+
17
+ let(:host) { instance_double(Beaker::Host) }
18
+
19
+ describe '#install_puppet_module_via_pmt_on' do
20
+ let(:default_module_install_opts) { nil }
21
+
22
+ before do
23
+ allow(host).to receive(:[]).with(:default_module_install_opts).and_return(default_module_install_opts)
24
+ end
25
+
26
+ it 'installs module via puppet module tool' do
27
+ expect(Beaker::PuppetCommand).to receive(:new).with('module', %w[install test], {}).once
28
+ expect(dsl).to receive(:on).with(host, anything).once
29
+
30
+ dsl.install_puppet_module_via_pmt_on(host, 'test')
31
+ end
32
+
33
+ it 'accepts the version parameter' do
34
+ expect(Beaker::PuppetCommand).to receive(:new).with('module', %w[install test], { version: '1.2.3' }).once
35
+ expect(dsl).to receive(:on).with(host, anything).once
36
+
37
+ dsl.install_puppet_module_via_pmt_on(host, 'test', '1.2.3')
38
+ end
39
+
40
+ it 'accepts the module_repository parameter' do
41
+ expect(Beaker::PuppetCommand).to receive(:new).with('module', %w[install test], { module_repository: 'http://forge.example.com' }).once
42
+ expect(dsl).to receive(:on).with(host, anything).once
43
+
44
+ dsl.install_puppet_module_via_pmt_on(host, 'test', nil, 'http://forge.example.com')
45
+ end
46
+
47
+ it 'accepts the version and module_repository parameters' do
48
+ expect(Beaker::PuppetCommand).to receive(:new).with('module', %w[install test], { version: '1.2.3', module_repository: 'http://forge.example.com' }).once
49
+ expect(dsl).to receive(:on).with(host, anything).once
50
+
51
+ dsl.install_puppet_module_via_pmt_on(host, 'test', '1.2.3', 'http://forge.example.com')
52
+ end
53
+
54
+ context 'with host with trace option' do
55
+ let(:default_module_install_opts) { { trace: nil } }
56
+
57
+ it 'takes the trace option and passes it down correctly' do
58
+ expect(Beaker::PuppetCommand).to receive(:new).with('module', %w[install test], { trace: nil }).once
59
+ expect(dsl).to receive(:on).with(host, anything).once
60
+
61
+ dsl.install_puppet_module_via_pmt_on(host, 'test')
62
+ end
63
+ end
64
+
65
+ context 'with host with module_repository set' do
66
+ let(:default_module_install_opts) { { module_repository: 'http://forge.example.com' } }
67
+
68
+ it 'passes it down' do
69
+ expect(Beaker::PuppetCommand).to receive(:new).with('module', %w[install test], { module_repository: 'http://forge.example.com' }).once
70
+ expect(dsl).to receive(:on).with(host, anything).once
71
+
72
+ dsl.install_puppet_module_via_pmt_on(host, 'test')
73
+ end
74
+
75
+ it 'argument overrides host defaults' do
76
+ expect(Beaker::PuppetCommand).to receive(:new).with('module', %w[install test], { module_repository: 'http://other.example.com' }).once
77
+ expect(dsl).to receive(:on).with(host, anything).once
78
+
79
+ dsl.install_puppet_module_via_pmt_on(host, 'test', nil, 'http://other.example.com')
80
+ end
81
+ end
82
+ end
83
+
84
+ describe '#install_local_module_on' do
85
+ let(:builder) { instance_double(Puppet::Modulebuilder::Builder) }
86
+
87
+ it 'builds and copies the module' do
88
+ expect(File).to receive(:realpath).with('.').and_return('/path/to/module')
89
+ allow(File).to receive(:unlink).with('/path/to/tarball')
90
+ expect(Puppet::Modulebuilder::Builder).to receive(:new).with('/path/to/module').and_return(builder)
91
+ expect(builder).to receive(:build).and_return('/path/to/tarball')
92
+
93
+ expect(host).to receive(:tmpfile).with('puppet_module').and_return('temp')
94
+ expect(host).to receive(:do_scp_to).with('/path/to/tarball', 'temp', {})
95
+ expect(dsl).to receive(:install_puppet_module_via_pmt_on).with(host, 'temp')
96
+ expect(host).to receive(:rm_rf).with('temp')
97
+
98
+ dsl.install_local_module_on(host)
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'beaker_puppet_helpers'
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: beaker_puppet_helpers
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Vox Pupuli
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-05-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: beaker
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '4'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '6'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '4'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '6'
33
+ - !ruby/object:Gem::Dependency
34
+ name: puppet-modulebuilder
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '0.3'
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '2'
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '0.3'
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '2'
53
+ description: For use for the Beaker acceptance testing tool
54
+ email:
55
+ - voxpupuli@groups.io
56
+ executables: []
57
+ extensions: []
58
+ extra_rdoc_files: []
59
+ files:
60
+ - ".github/dependabot.yml"
61
+ - ".github/workflows/release.yml"
62
+ - ".github/workflows/test.yml"
63
+ - ".gitignore"
64
+ - ".rubocop.yml"
65
+ - ".rubocop_todo.yml"
66
+ - CHANGELOG.md
67
+ - Gemfile
68
+ - LICENSE
69
+ - README.md
70
+ - Rakefile
71
+ - acceptance/dummy/manifests/init.pp
72
+ - acceptance/dummy/metadata.json
73
+ - acceptance/tests/install_utils.rb
74
+ - acceptance/tests/module_utils.rb
75
+ - beaker_puppet_helpers.gemspec
76
+ - lib/beaker_puppet_helpers.rb
77
+ - lib/beaker_puppet_helpers/dsl.rb
78
+ - lib/beaker_puppet_helpers/install_utils.rb
79
+ - lib/beaker_puppet_helpers/module_utils.rb
80
+ - spec/beaker_puppet_helpers/dsl_spec.rb
81
+ - spec/beaker_puppet_helpers/install_utils_spec.rb
82
+ - spec/beaker_puppet_helpers/module_utils_spec.rb
83
+ - spec/spec_helper.rb
84
+ homepage: https://github.com/voxpupuli/beaker_puppet_helpers
85
+ licenses:
86
+ - Apache-2.0
87
+ metadata: {}
88
+ post_install_message:
89
+ rdoc_options: []
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '2.7'
97
+ - - "<"
98
+ - !ruby/object:Gem::Version
99
+ version: '4'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubygems_version: 3.2.33
107
+ signing_key:
108
+ specification_version: 4
109
+ summary: Beaker's Puppet DSL Extension Helpers
110
+ test_files: []