|
| 1 | +require 'spec_helper' |
| 2 | + |
| 3 | +describe 'gocd::agent' do |
| 4 | + shared_examples_for :agent_recipe do |
| 5 | + it 'includes java recipe' do |
| 6 | + expect(chef_run).to include_recipe('java::default') |
| 7 | + end |
| 8 | + it 'installs go-agent package' do |
| 9 | + expect(chef_run).to install_package('go-agent') |
| 10 | + end |
| 11 | + it 'creates go agent configuration in /etc/default/go-agent' do |
| 12 | + expect(chef_run).to render_file('/etc/default/go-agent').with_content { |content| |
| 13 | + expect(content).to_not include('java-6') |
| 14 | + } |
| 15 | + end |
| 16 | + it 'configures go-agent service' do |
| 17 | + expect(chef_run).to enable_service('go-agent') |
| 18 | + expect(chef_run).to start_service('go-agent') |
| 19 | + end |
| 20 | + end |
| 21 | + |
| 22 | + context 'When all attributes are default and platform is debian' do |
| 23 | + let(:chef_run) do |
| 24 | + run = ChefSpec::SoloRunner.new do |node| |
| 25 | + node.automatic['lsb']['id'] = 'Debian' |
| 26 | + node.automatic['platform_family'] = 'debian' |
| 27 | + node.automatic['platform'] = 'debian' |
| 28 | + node.automatic['os'] = 'linux' |
| 29 | + end |
| 30 | + run.converge(described_recipe) |
| 31 | + end |
| 32 | + it_behaves_like :agent_recipe |
| 33 | + it_behaves_like :apt_repository_recipe |
| 34 | + end |
| 35 | + context 'When all attributes are default and platform is centos' do |
| 36 | + let(:chef_run) do |
| 37 | + run = ChefSpec::SoloRunner.new do |node| |
| 38 | + node.automatic['platform_family'] = 'rhel' |
| 39 | + node.automatic['platform'] = 'centos' |
| 40 | + node.automatic['os'] = 'linux' |
| 41 | + end |
| 42 | + run.converge(described_recipe) |
| 43 | + end |
| 44 | + it_behaves_like :agent_recipe |
| 45 | + it_behaves_like :yum_repository_recipe |
| 46 | + end |
| 47 | + #TODO: agent on windows |
| 48 | +end |
0 commit comments