-
Notifications
You must be signed in to change notification settings - Fork 13
/
default_spec.rb
81 lines (63 loc) · 2.58 KB
/
default_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
require 'chefspec'
require 'chefspec/berkshelf'
require 'spec_helper.rb'
shared_examples 'general tests' do |platform, version|
context "on #{platform} #{version}" do
let(:chef_run) do
ChefSpec::Runner.new(
platform: platform,
version: version,
step_into: [ 'anaconda_package' ]) do |node|
#version: version) do |node|
#node.set['foo']['users'] = users
end
end
before do
stub_command('/opt/anaconda/2.0.1/bin/conda install astroid --yes').and_return(true)
stub_command('/opt/anaconda/2.0.1/bin/conda remove astroid --yes').and_return(true)
end
it 'runs without errors. see test-kitchen tests for more comprehensive tests that are not possible here' do
chef_run.converge(described_recipe)
expect(chef_run).to create_directory('/opt/anaconda')
expect(chef_run).to run_bash('run anaconda installer')
end
it 'generates the installer template correctly' do
chef_run.converge(described_recipe)
# must be exactly 4 lines
installer_config_path = "#{Chef::Config[:file_cache_path]}/installer_config"
expect(chef_run).to render_file(installer_config_path).with_content(/.*\n.*\n.*\n.*/)
end
it 'exposes the anaconda_package resource' do
chef_run.converge('recipe[anaconda::package_tests]')
expect(chef_run).to install_conda_package('astroid')
expect(chef_run).to remove_conda_package('astroid')
# for coverage
expect(chef_run).to write_log('do NOT include this in your runlist! for testing only.')
end
it 'provides a convenience shell script' do
chef_run.converge('recipe[anaconda::shell_conveniences]')
expect(chef_run).to create_template('/etc/profile.d/anaconda-env.sh')
end
it 'caches the installer template' do
chef_run.converge(described_recipe)
installer = "Anaconda-#{chef_run.node.anaconda.version}-Linux-#{chef_run.node.anaconda.flavor}.sh"
installer_path = "#{Chef::Config[:file_cache_path]}/#{installer}"
expect(chef_run).to create_remote_file_if_missing(installer_path)
end
end
end
describe 'anaconda::default' do
platforms = {
# for whatever reason there's no fauxhai data for 12.10
'ubuntu' => [ '12.04', '13.04', '13.10', '14.04' ],
'debian' => [ '6.0.5' ],
'centos' => [ '5.8', '6.0', '6.3' ],
'redhat' => [ '5.8', '6.3' ],
}
platforms.each do |platform, versions|
versions.each do |platform_version|
Fauxhai.mock(platform: platform, version: platform_version)
include_examples 'general tests', platform, platform_version
end
end
end