|
131 | 131 | [{ 'uri' => 'some.host', 'facts' => { 'provisioner' => 'docker', 'container_name' => 'foo', 'platform' => 'some.host' } }] }] }
|
132 | 132 | end
|
133 | 133 | let(:targets) { ['some.host'] }
|
134 |
| - let(:params) { { 'collection' => 'puppet6' } } |
| 134 | + let(:token) { 'some_token' } |
| 135 | + let(:params) { { 'collection' => 'puppet6', 'password' => token } } |
135 | 136 |
|
136 | 137 | it 'calls function' do
|
| 138 | + allow(ENV).to receive(:fetch).with('PUPPET_VERSION', nil).and_return(nil) |
| 139 | + allow(ENV).to receive(:fetch).with('PUPPET_FORGE_TOKEN', nil).and_return(token) |
137 | 140 | allow(File).to receive(:directory?).with(File.join(described_class::DEFAULT_CONFIG_DATA['modulepath'], 'puppet_agent')).and_return(true)
|
138 | 141 | allow_any_instance_of(BoltSpec::Run).to receive(:run_task).with('puppet_agent::install', targets, params, config: described_class::DEFAULT_CONFIG_DATA, inventory: inventory_hash).and_return([])
|
139 | 142 | install_agent('puppet6', targets, inventory_hash)
|
140 | 143 | end
|
| 144 | + |
| 145 | + it 'adds puppet version' do |
| 146 | + params = { 'collection' => 'puppet7', 'version' => '7.35.0' } |
| 147 | + allow(ENV).to receive(:fetch).with('PUPPET_VERSION', nil).and_return('7.35.0') |
| 148 | + allow(ENV).to receive(:fetch).with('PUPPET_FORGE_TOKEN', nil).and_return(nil) |
| 149 | + allow(File).to receive(:directory?).with(File.join(described_class::DEFAULT_CONFIG_DATA['modulepath'], 'puppet_agent')).and_return(true) |
| 150 | + allow_any_instance_of(BoltSpec::Run).to receive(:run_task).with('puppet_agent::install', targets, params, config: described_class::DEFAULT_CONFIG_DATA, inventory: inventory_hash).and_return([]) |
| 151 | + install_agent('puppet7', targets, inventory_hash) |
| 152 | + end |
| 153 | + |
| 154 | + it 'fails for puppetcore if no token supplied' do |
| 155 | + params = { 'collection' => 'puppetcore7' } |
| 156 | + allow(ENV).to receive(:fetch).with('PUPPET_VERSION', nil).and_return(nil) |
| 157 | + allow(ENV).to receive(:fetch).with('PUPPET_FORGE_TOKEN', nil).and_return(nil) |
| 158 | + allow(File).to receive(:directory?).with(File.join(described_class::DEFAULT_CONFIG_DATA['modulepath'], 'puppet_agent')).and_return(true) |
| 159 | + allow_any_instance_of(BoltSpec::Run).to receive(:run_task).with('puppet_agent::install', targets, params, config: described_class::DEFAULT_CONFIG_DATA, inventory: inventory_hash).and_return([]) |
| 160 | + expect { install_agent('puppetcore7', targets, inventory_hash) }.to raise_error(RuntimeError, /puppetcore agent installs require a valid PUPPET_FORGE_TOKEN set in the env\./) |
| 161 | + end |
141 | 162 | end
|
142 | 163 |
|
143 | 164 | context 'with install_module' do
|
|
0 commit comments