Switch to puppetlabs/apt

(imported from commit b2f581280dc7877051ef79d86eac671bfd455ace)
This commit is contained in:
Luke Faraone
2014-01-30 14:28:59 -05:00
parent 364bbf08cf
commit aa52475e96
301 changed files with 12221 additions and 1120 deletions

View File

@@ -0,0 +1,37 @@
#! /usr/bin/env ruby -S rspec
require 'spec_helper'
require 'rspec-puppet'
describe 'defined_with_params' do
describe 'when a resource is not specified' do
it { should run.with_params().and_raise_error(ArgumentError) }
end
describe 'when compared against a resource with no attributes' do
let :pre_condition do
'user { "dan": }'
end
it do
should run.with_params('User[dan]', {}).and_return(true)
should run.with_params('User[bob]', {}).and_return(false)
should run.with_params('User[dan]', {'foo' => 'bar'}).and_return(false)
end
end
describe 'when compared against a resource with attributes' do
let :pre_condition do
'user { "dan": ensure => present, shell => "/bin/csh", managehome => false}'
end
it do
should run.with_params('User[dan]', {}).and_return(true)
should run.with_params('User[dan]', '').and_return(true)
should run.with_params('User[dan]', {'ensure' => 'present'}
).and_return(true)
should run.with_params('User[dan]',
{'ensure' => 'present', 'managehome' => false}
).and_return(true)
should run.with_params('User[dan]',
{'ensure' => 'absent', 'managehome' => false}
).and_return(false)
end
end
end

View File

@@ -0,0 +1,42 @@
#! /usr/bin/env ruby
require 'spec_helper'
require 'rspec-puppet'
describe 'ensure_packages' do
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
describe 'argument handling' do
it 'fails with no arguments' do
should run.with_params().and_raise_error(Puppet::ParseError)
end
it 'requires an array' do
lambda { scope.function_ensure_packages([['foo']]) }.should_not raise_error
end
it 'fails when given a string' do
should run.with_params('foo').and_raise_error(Puppet::ParseError)
end
end
context 'given a catalog containing Package[puppet]{ensure => absent}' do
let :pre_condition do
'package { puppet: ensure => absent }'
end
# NOTE: should run.with_params has the side effect of making the compiler
# available to the test harness.
it 'has no effect on Package[puppet]' do
should run.with_params(['puppet'])
rsrc = compiler.catalog.resource('Package[puppet]')
rsrc.to_hash.should == {:ensure => "absent"}
end
end
context 'given a clean catalog' do
it 'declares package resources with ensure => present' do
should run.with_params(['facter'])
rsrc = compiler.catalog.resource('Package[facter]')
rsrc.to_hash.should == {:name => "facter", :ensure => "present"}
end
end
end

View File

@@ -0,0 +1,64 @@
#! /usr/bin/env ruby -S rspec
require 'spec_helper'
require 'rspec-puppet'
describe 'ensure_resource' do
describe 'when a type or title is not specified' do
it { should run.with_params().and_raise_error(ArgumentError) }
it { should run.with_params(['type']).and_raise_error(ArgumentError) }
end
describe 'when compared against a resource with no attributes' do
let :pre_condition do
'user { "dan": }'
end
it "should contain the the ensured resources" do
subject.should run.with_params('user', 'dan', {})
compiler.catalog.resource('User[dan]').to_s.should == 'User[dan]'
end
end
describe 'when compared against a resource with attributes' do
let :pre_condition do
'user { "dan": ensure => present, shell => "/bin/csh", managehome => false}'
end
# these first three should not fail
it { should run.with_params('User', 'dan', {}) }
it { should run.with_params('User', 'dan', '') }
it { should run.with_params('User', 'dan', {'ensure' => 'present'}) }
it { should run.with_params('User', 'dan', {'ensure' => 'present', 'managehome' => false}) }
# test that this fails
it { should run.with_params('User', 'dan', {'ensure' => 'absent', 'managehome' => false}).and_raise_error(Puppet::Error) }
end
describe 'when an array of new resources are passed in' do
it "should contain the ensured resources" do
subject.should run.with_params('User', ['dan', 'alex'], {})
compiler.catalog.resource('User[dan]').to_s.should == 'User[dan]'
compiler.catalog.resource('User[alex]').to_s.should == 'User[alex]'
end
end
describe 'when an array of existing resources is compared against existing resources' do
let :pre_condition do
'user { "dan": ensure => present; "alex": ensure => present }'
end
it "should return the existing resources" do
subject.should run.with_params('User', ['dan', 'alex'], {})
compiler.catalog.resource('User[dan]').to_s.should == 'User[dan]'
compiler.catalog.resource('User[alex]').to_s.should == 'User[alex]'
end
end
describe 'when compared against existing resources with attributes' do
let :pre_condition do
'user { "dan": ensure => present; "alex": ensure => present }'
end
# These should not fail
it { should run.with_params('User', ['dan', 'alex'], {}) }
it { should run.with_params('User', ['dan', 'alex'], '') }
it { should run.with_params('User', ['dan', 'alex'], {'ensure' => 'present'}) }
# This should fail
it { should run.with_params('User', ['dan', 'alex'], {'ensure' => 'absent'}).and_raise_error(Puppet::Error) }
end
end

View File

@@ -0,0 +1,34 @@
#! /usr/bin/env ruby -S rspec
require 'spec_helper'
require 'rspec-puppet'
describe 'getparam' do
describe 'when a resource is not specified' do
it do
should run.with_params().and_raise_error(ArgumentError)
should run.with_params('User[dan]').and_raise_error(ArgumentError)
should run.with_params('User[dan]', {}).and_raise_error(ArgumentError)
should run.with_params('User[dan]', '').and_return('')
end
end
describe 'when compared against a resource with no params' do
let :pre_condition do
'user { "dan": }'
end
it do
should run.with_params('User[dan]', 'shell').and_return('')
end
end
describe 'when compared against a resource with params' do
let :pre_condition do
'user { "dan": ensure => present, shell => "/bin/sh", managehome => false}'
end
it do
should run.with_params('User[dan]', 'shell').and_return('/bin/sh')
should run.with_params('User[dan]', '').and_return('')
should run.with_params('User[dan]', 'ensure').and_return('present')
should run.with_params('User[dan]', 'managehome').and_return(false)
end
end
end