-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add integration tests for repo installs
- Loading branch information
1 parent
4591778
commit d9b75d4
Showing
11 changed files
with
204 additions
and
3 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
File renamed without changes.
38 changes: 38 additions & 0 deletions
38
test/integration/repo/serverspec/localhost/environment_spec.rb
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,38 @@ | ||
# encoding: utf-8 | ||
# frozen_string_literal: true | ||
|
||
require_relative '../spec_helper' | ||
|
||
describe 'chef-dk::repo::environment' do | ||
shared_examples_for 'file with chef shell-init' do | ||
it 'contains the chef shell-init command' do | ||
matcher = /^eval "\$\(chef shell-init bash\)"$/ | ||
expect(subject.content).to match(matcher) | ||
end | ||
end | ||
|
||
describe file('/etc/bashrc'), | ||
if: %w(darwin redhat fedora).include?(os[:family]) do | ||
it_behaves_like 'file with chef shell-init' | ||
end | ||
|
||
describe file('/etc/bash.bashrc'), | ||
if: %w(ubuntu debian).include?(os[:family]) do | ||
it_behaves_like 'file with chef shell-init' | ||
end | ||
|
||
describe command('/opt/chefdk/embedded/bin/gem list cabin'), | ||
if: os[:family] != 'windows' do | ||
it 'shows the requested gem is installed' do | ||
expect(subject.stdout).to match(/^cabin \(/) | ||
end | ||
end | ||
|
||
describe file( | ||
'~/AppData/Local/chefdk/gem/ruby/2.1.0/bin/rubygems-cabin-test' | ||
), if: os[:family] == 'windows' do | ||
it 'shows the requested gem is installed' do | ||
expect(subject).to exist | ||
end | ||
end | ||
end |
52 changes: 52 additions & 0 deletions
52
test/integration/repo/serverspec/localhost/package_spec.rb
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,52 @@ | ||
# encoding: utf-8 | ||
# frozen_string_literal: true | ||
|
||
require_relative '../spec_helper' | ||
|
||
describe 'chef-dk::repo::package' do | ||
describe command('brew list chefdk'), if: os[:family] == 'darwin' do | ||
it 'indicates Chef-DK is installed' do | ||
expect(subject.exit_status).to eq(0) | ||
end | ||
end | ||
|
||
describe command('chocolatey list chefdk'), if: os[:family] == 'windows' do | ||
it 'indicates Chef-DK is installed' do | ||
expect(subject.exit_status).to eq(0) | ||
end | ||
end | ||
|
||
describe file('/etc/apt/sources.list.d/chef-stable.list'), | ||
if: %w(ubuntu debian).include?(os[:family]) do | ||
it 'exists' do | ||
expect(subject).to be_file | ||
end | ||
end | ||
|
||
describe file('/etc/yum.repos.d/chef-stable.repo'), | ||
if: %w(redhat fedora).include?(os[:family]) do | ||
it 'exists' do | ||
expect(subject).to be_file | ||
end | ||
end | ||
|
||
describe package('com.getchef.pkg.chefdk'), if: os[:family] == 'darwin' do | ||
it 'is installed' do | ||
expect(subject).to be_installed.by(:pkgutil) | ||
end | ||
end | ||
|
||
# On Windows, the package name changes to reflect each ChefDK version | ||
describe package('Chef Development Kit v*'), if: os[:family] == 'windows' do | ||
it 'is installed' do | ||
expect(subject).to be_installed | ||
end | ||
end | ||
|
||
describe package('chefdk'), | ||
if: %w(ubuntu debian redhat fedora).include?(os[:family]) do | ||
it 'is installed' do | ||
expect(subject).to be_installed | ||
end | ||
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# encoding: utf-8 | ||
# frozen_string_literal: true | ||
|
||
require 'serverspec' | ||
|
||
if RUBY_PLATFORM =~ /mswin|mingw32|windows/ | ||
set :os, family: 'windows' | ||
set :backend, :cmd | ||
else | ||
set :backend, :exec | ||
end |
38 changes: 38 additions & 0 deletions
38
test/integration/repo_remove/serverspec/localhost/environment_spec.rb
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,38 @@ | ||
# encoding: utf-8 | ||
# frozen_string_literal: true | ||
|
||
require_relative '../spec_helper' | ||
|
||
describe 'chef-dk::repo_remove::environment' do | ||
shared_examples_for 'file without chef shell-init' do | ||
it 'does not contain the chef shell-init command' do | ||
matcher = /^eval "\$\(chef shell-init bash\)"$/ | ||
expect(subject.content).to_not match(matcher) | ||
end | ||
end | ||
|
||
describe file('/etc/bashrc'), | ||
if: %w(darwin redhat fedora).include?(os[:family]) do | ||
it_behaves_like 'file without chef shell-init' | ||
end | ||
|
||
describe file('/etc/bash.bashrc'), | ||
if: %w(ubuntu debian).include?(os[:family]) do | ||
it_behaves_like 'file without chef shell-init' | ||
end | ||
|
||
describe file('~/.chefdk/gem/ruby/2.1.0/bin/rubygems-cabin-test'), | ||
if: os[:family] != 'windows' do | ||
it 'does not exist' do | ||
expect(subject).to_not exist | ||
end | ||
end | ||
|
||
describe file( | ||
'~/AppData/Local/chefdk/gem/ruby/2.1.0/bin/rubygems-cabin-test' | ||
), if: os[:family] == 'windows' do | ||
it 'does not exist' do | ||
expect(subject).to_not exist | ||
end | ||
end | ||
end |
38 changes: 38 additions & 0 deletions
38
test/integration/repo_remove/serverspec/localhost/package_spec.rb
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,38 @@ | ||
# encoding: utf-8 | ||
# frozen_string_literal: true | ||
|
||
require_relative '../spec_helper' | ||
|
||
describe 'chef-dk::repo_remove::package' do | ||
describe command('brew list chefdk'), if: os[:family] == 'darwin' do | ||
it 'indicates Chef-DK is not installed' do | ||
expect(subject.exit_status).to eq(1) | ||
end | ||
end | ||
|
||
describe command('chocolatey list chefdk'), if: os[:family] == 'windows' do | ||
it 'indicates Chef-DK is not installed' do | ||
expect(subject.exit_status).to eq(1) | ||
end | ||
end | ||
|
||
describe package('com.getchef.pkg.chefdk'), if: os[:family] == 'darwin' do | ||
it 'is not installed' do | ||
expect(subject).to_not be_installed.by(:pkgutil) | ||
end | ||
end | ||
|
||
# On Windows, the package name changes to reflect each ChefDK version | ||
describe package('Chef Development Kit v*'), if: os[:family] == 'windows' do | ||
it 'is not installed' do | ||
expect(subject).to_not be_installed | ||
end | ||
end | ||
|
||
describe package('chefdk'), | ||
if: %w(ubuntu debian redhat fedora).include?(os[:family]) do | ||
it 'is not installed' do | ||
expect(subject).to_not be_installed | ||
end | ||
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# encoding: utf-8 | ||
# frozen_string_literal: true | ||
|
||
require 'serverspec' | ||
|
||
if RUBY_PLATFORM =~ /mswin|mingw32|windows/ | ||
set :os, family: 'windows' | ||
set :backend, :cmd | ||
else | ||
set :backend, :exec | ||
end |