Skip to content

Commit 487e283

Browse files
author
David Balatero
committed
Added a passing feature set for the Macports recipe set. Any future
integration tests against package repositories should use this as an example of quick, light package testing.
1 parent eceebb7 commit 487e283

9 files changed

Lines changed: 69 additions & 0 deletions

File tree

‎features/data/cookbooks/packages/recipes/default.rb‎

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package "fdsafdsa" do
2+
action :install
3+
end
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package "yydecode" do
2+
action :install
3+
end
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package "yydecode" do
2+
action :purge
3+
end
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package "yydecode" do
2+
action :remove
3+
end
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package "yydecode" do
2+
action :remove
3+
end
4+
5+
package "yydecode" do
6+
action :upgrade
7+
end
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Feature: Macports integration
2+
In order to easily manage my OS X machines
3+
As a Developer
4+
I want to manage packages installed on OS X machines
5+
6+
Scenario Outline: OS X package management
7+
Given that I have the MacPorts package system installed
8+
When I run chef-solo with the '<recipe>' recipe
9+
Then the run should exit '<exitcode>'
10+
And there <should> be a binary on the path called '<binary>'
11+
12+
Examples:
13+
| recipe | binary | should | exitcode |
14+
| packages::macports_install_yydecode | yydecode | should | 0 |
15+
| packages::macports_remove_yydecode | yydecode | should not | 0 |
16+
| packages::macports_upgrade_yydecode | yydecode | should | 0 |
17+
| packages::macports_purge_yydecode | yydecode | should not | 0 |
18+
| packages::macports_install_bad_package | fdsafdsa | should not | 1 |

‎features/steps/packages.rb‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Given /^that I have the (.+) package system installed$/ do |package_system|
2+
unless package_system_available?(package_system)
3+
pending "This Cucumber feature will not execute, as it is missing the #{package_system} packaging system."
4+
end
5+
end
6+
7+
Then /^there should be a binary on the path called '(.+)'$/ do |binary_name|
8+
binary_name.strip!
9+
result = `which #{binary_name}`
10+
result.should_not =~ /not found/
11+
end
12+
13+
Then /^there should not be a binary on the path called '(.+)'$/ do |binary_name|
14+
binary_name.strip!
15+
result = `which #{binary_name}`.strip
16+
17+
unless result.empty?
18+
result.should =~ /not found/
19+
end
20+
end

‎features/support/packages.rb‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Provides a method to quickly lookup whether we have
2+
# a given packaging system installed.
3+
def package_system_available?(name)
4+
case name
5+
when 'MacPorts'
6+
uname = `uname`
7+
port = `which port`
8+
(uname =~ /Darwin/ and !port.match(/not found/))
9+
else
10+
false
11+
end
12+
end

0 commit comments

Comments
 (0)