forked from gocd/go-cookbook
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gocd#52 chefspec with shared examples for Go server on rhel and debian
we force java to 7 - user does not have to set it anymore removed ubuntu 14.10 and 13.10 from test suites - they are EOF and very similar to LTS anyway
- Loading branch information
Showing
9 changed files
with
63 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# must be early so that java home attrbute gets assigned soon enough | ||
node.force_default['java']['jdk_version'] = '7' | ||
include_recipe 'java' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,48 @@ | ||
require 'spec_helper' | ||
|
||
describe 'gocd::server' do | ||
describe 'debian' do | ||
let(:chef_run) do | ||
run = ChefSpec::SoloRunner.new do |node| | ||
node.automatic['lsb']['id'] = 'Debian' | ||
node.automatic['platform_family'] = 'debian' | ||
node.automatic['platform'] = 'debian' | ||
node.automatic['os'] = 'linux' | ||
node.normal['java']['jdk_version'] = '7' | ||
end | ||
run.converge(described_recipe) | ||
end | ||
|
||
it 'includes apt recipe' do | ||
expect(chef_run).to include_recipe('apt::default') | ||
end | ||
shared_examples_for :server_recipe do | ||
it 'includes java recipe' do | ||
expect(chef_run).to include_recipe('java::default') | ||
end | ||
it 'adds thoughtworks apt repository' do | ||
expect(chef_run).to add_apt_repository('gocd') | ||
end | ||
it 'installs go-server apt package' do | ||
it 'installs go-server package' do | ||
expect(chef_run).to install_package('go-server') | ||
end | ||
|
||
it 'creates go server configuration in /etc/default/go-server' do | ||
expect(chef_run).to render_file('/etc/default/go-server').with_content { |content| | ||
expect(content).to_not include('java-6-openjdk') | ||
expect(content).to_not include('java-6') | ||
} | ||
end | ||
it 'configures go-server service' do | ||
expect(chef_run).to enable_service('go-server') | ||
expect(chef_run).to start_service('go-server') | ||
end | ||
end | ||
|
||
context 'When all attributes are default and platform is debian' do | ||
let(:chef_run) do | ||
run = ChefSpec::SoloRunner.new do |node| | ||
node.automatic['lsb']['id'] = 'Debian' | ||
node.automatic['platform_family'] = 'debian' | ||
node.automatic['platform'] = 'debian' | ||
node.automatic['os'] = 'linux' | ||
end | ||
run.converge(described_recipe) | ||
end | ||
it_behaves_like :server_recipe | ||
it_behaves_like :apt_repository_recipe | ||
end | ||
context 'When all attributes are default and platform is centos' do | ||
let(:chef_run) do | ||
run = ChefSpec::SoloRunner.new do |node| | ||
node.automatic['platform_family'] = 'rhel' | ||
node.automatic['platform'] = 'centos' | ||
node.automatic['os'] = 'linux' | ||
end | ||
run.converge(described_recipe) | ||
end | ||
it_behaves_like :server_recipe | ||
it_behaves_like :yum_repository_recipe | ||
end | ||
#TODO: server on windows | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
shared_examples_for :apt_repository_recipe do | ||
it 'includes apt recipe' do | ||
expect(chef_run).to include_recipe('apt') | ||
end | ||
it 'adds gocd apt repository' do | ||
expect(chef_run).to add_apt_repository('gocd') | ||
end | ||
end | ||
shared_examples_for :yum_repository_recipe do | ||
it 'includes yum recipe' do | ||
expect(chef_run).to include_recipe('yum') | ||
end | ||
it 'adds gocd yum repository' do | ||
expect(chef_run).to create_yum_repository('gocd') | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
require 'chefspec' | ||
require 'chefspec/berkshelf' | ||
require_relative 'shared_examples' | ||
ChefSpec::Coverage.start! |