Skip to content

Commit

Permalink
Initial tests for samba::share
Browse files Browse the repository at this point in the history
  • Loading branch information
Pete Brown committed Jul 5, 2016
1 parent ac7073b commit 52b8916
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--format documentation
--color
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ group :test do

gem "puppet-syntax"
gem "puppetlabs_spec_helper"
gem 'rspec-puppet-facts'
end
103 changes: 103 additions & 0 deletions spec/defines/samba__server__share_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
require 'spec_helper'

describe 'samba::server::share', :type => :define do
let(:pre_condition){ 'class{"samba::server":}'}
on_supported_os.each do |os, facts|
context "When on an #{os} system" do
let(:facts) do
facts.merge({
:concat_basedir => '/tmp',
:domain => 'domain.com'
})
end

context 'when called with base options' do
let(:title) { 'test_share' }
let(:params) {{
:ensure => 'present'
}}

it { is_expected.to contain_samba__server__share('test_share') }
it { is_expected.to contain_augeas('test_share-section').with(
:incl => '/etc/samba/smb.conf',
:lens => 'Samba.lns',
:context => '/files/etc/samba/smb.conf',
:changes => ["set target[. = 'test_share'] 'test_share'"]
).that_requires('Class[Samba::Server::Config]'
).that_notifies('Class[Samba::Server::Service]')
}
it { is_expected.to contain_augeas('test_share-changes').with(
:incl => '/etc/samba/smb.conf',
:lens => 'Samba.lns',
:context => '/files/etc/samba/smb.conf',
).that_requires('Class[Samba::Server::Config]'
).that_notifies('Class[Samba::Server::Service]')
}
end#no params

context 'when called with ensure set to absent' do
let(:title) { 'test_share' }
let(:params) {{
:ensure => 'absent'
}}

it 'should not contain the share' do
skip 'this is not working'
should_not contain_samba__server__share('test_share')
end
end#no params

context 'when called with available set to true' do
let(:title) { 'test_share' }
let(:params) {{
:ensure => 'present',
:available => true,
}}
it { is_expected.to contain_samba__server__share('test_share') }
it { is_expected.to contain_augeas('test_share-section').with(
:incl => '/etc/samba/smb.conf',
:lens => 'Samba.lns',
:context => '/files/etc/samba/smb.conf',
:changes => ["set target[. = 'test_share'] 'test_share'"]
).that_requires('Class[Samba::Server::Config]'
).that_notifies('Class[Samba::Server::Service]')
}
it { is_expected.to contain_augeas('test_share-changes').with(
:incl => '/etc/samba/smb.conf',
:lens => 'Samba.lns',
:context => '/files/etc/samba/smb.conf',
:changes => ["set \"target[. = 'test_share']/available\" yes"]
).that_requires('Class[Samba::Server::Config]'
).that_notifies('Class[Samba::Server::Service]')
}
end#no params

context 'when called with root_preexec set to something' do
let(:title) { 'test_share' }
let(:params) {{
:ensure => 'present',
:root_preexec => '/bin/true',
}}
it { is_expected.to contain_samba__server__share('test_share') }
it { is_expected.to contain_augeas('test_share-section').with(
:incl => '/etc/samba/smb.conf',
:lens => 'Samba.lns',
:context => '/files/etc/samba/smb.conf',
:changes => ["set target[. = 'test_share'] 'test_share'"]
).that_requires('Class[Samba::Server::Config]'
).that_notifies('Class[Samba::Server::Service]')
}
it { is_expected.to contain_augeas('test_share-changes').with(
:incl => '/etc/samba/smb.conf',
:lens => 'Samba.lns',
:context => '/files/etc/samba/smb.conf',
:changes => ["set \"target[. = 'test_share']/root_preexec\" /bin/true"]
).that_requires('Class[Samba::Server::Config]'
).that_notifies('Class[Samba::Server::Service]')
}
end#no params

end
end
end

6 changes: 6 additions & 0 deletions spec/spec.opts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
--format
s
--colour
--loadby
mtime
--backtrace
3 changes: 3 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
require 'puppetlabs_spec_helper/module_spec_helper'
require 'rspec-puppet-facts'

include RspecPuppetFacts

RSpec.configure do |c|
c.before do
Expand Down

0 comments on commit 52b8916

Please sign in to comment.