Skip to content

Commit

Permalink
added acceptance tests for package_settings
Browse files Browse the repository at this point in the history
  • Loading branch information
ptomulik committed Sep 10, 2016
1 parent 1713077 commit 970ade5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
2016-09-10 Paweł Tomulik <ptomulik@meil.pw.edu.pl>
* added acceptance tests to test package_settings
* fixed typo in Vagrantfile
2016-06-24 Paweł Tomulik <ptomulik@meil.pw.edu.pl>
* minor revision to README.md
Expand Down
33 changes: 28 additions & 5 deletions spec/acceptance/portsng_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@

describe 'portsng provider' do

def package_setting(portname, optname)
cmd = "make -C /usr/ports/#{portname} showconfig | awk -F '[=:]' '/#{optname}/ {print $2}'"
shell(cmd).stdout.strip
end

skip_tests = true
case fact('osfamily')
when 'FreeBSD'
portname = 'textproc/jq'
portname = 'misc/ddate'
skip_tests = false
end

Expand Down Expand Up @@ -41,11 +46,11 @@
end
end

context "package {'#{portname}': package_settings => {'DOCS' => false} }" do
context "package {'#{portname}': package_settings => {'USFORMAT' => false} }" do
it 'runs without an error' do
pp = <<-PP
Package{ provider => portsng }
package{ '#{portname}': ensure => present, package_settings => {'DOCS' => false} }
package{ '#{portname}': ensure => present, package_settings => {'USFORMAT' => false} }
PP
# Run it twice for idempotency
apply_manifest(pp, :catch_failures => true)
Expand All @@ -55,13 +60,22 @@
describe package(portname) do
it { is_expected.to be_installed }
end
describe "package option USFORMAT" do
it { expect(package_setting(portname, 'USFORMAT')).to eq "off" }
end
describe "package option KILLBOB" do
it { expect(package_setting(portname, 'KILLBOB')).to eq "on" }
end
describe "package option PRAISEBOB" do
it { expect(package_setting(portname, 'PRAISEBOB')).to eq "off" }
end
end

context "package {'textproc/jq': package_settings => {'DOCS' => true}}" do
context "package {'#{portname}': package_settings => {'USFORMAT' => true}}" do
it 'runs without an error' do
pp = <<-PP
Package{ provider => portsng }
package{ '#{portname}': ensure => present, package_settings => {'DOCS' => true} }
package{ '#{portname}': ensure => present, package_settings => {'USFORMAT' => true} }
PP
# Run it twice for idempotency
apply_manifest(pp, :catch_failures => true)
Expand All @@ -71,5 +85,14 @@
describe package(portname) do
it { is_expected.to be_installed }
end
describe "package option USFORMAT" do
it { expect(package_setting(portname, 'USFORMAT')).to eq "on" }
end
describe "package option KILLBOB" do
it { expect(package_setting(portname, 'KILLBOB')).to eq "on" }
end
describe "package option PRAISEBOB" do
it { expect(package_setting(portname, 'PRAISEBOB')).to eq "off" }
end
end
end

0 comments on commit 970ade5

Please sign in to comment.