From 3ffd1bcbc1d203ad814038483cd49d332bbb7618 Mon Sep 17 00:00:00 2001 From: Adam Jahn Date: Fri, 1 Jul 2016 11:51:42 -0400 Subject: Pin json_pure below 2.0.0 for 1.8.7 support --- Gemfile | 1 + 1 file changed, 1 insertion(+) (limited to 'Gemfile') diff --git a/Gemfile b/Gemfile index a89c9e6..f90407b 100755 --- a/Gemfile +++ b/Gemfile @@ -20,6 +20,7 @@ group :test do gem "rspec", '< 3.2.0' gem "rspec-core", "3.1.7" gem "rspec-puppet", "~> 2.1" + gem "json_pure", "< 2.0.0" gem "puppet-syntax" gem "puppetlabs_spec_helper" -- cgit v1.2.3 From 52b8916a8754f397dfc65e055f52d10905e42d74 Mon Sep 17 00:00:00 2001 From: Pete Brown Date: Wed, 6 Jul 2016 00:03:45 +1000 Subject: Initial tests for samba::share --- .rspec | 2 + Gemfile | 1 + spec/defines/samba__server__share_spec.rb | 103 ++++++++++++++++++++++++++++++ spec/spec.opts | 6 ++ spec/spec_helper.rb | 3 + 5 files changed, 115 insertions(+) create mode 100644 .rspec create mode 100644 spec/defines/samba__server__share_spec.rb create mode 100644 spec/spec.opts (limited to 'Gemfile') diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..8c18f1a --- /dev/null +++ b/.rspec @@ -0,0 +1,2 @@ +--format documentation +--color diff --git a/Gemfile b/Gemfile index f90407b..598a68f 100755 --- a/Gemfile +++ b/Gemfile @@ -24,4 +24,5 @@ group :test do gem "puppet-syntax" gem "puppetlabs_spec_helper" + gem 'rspec-puppet-facts' end diff --git a/spec/defines/samba__server__share_spec.rb b/spec/defines/samba__server__share_spec.rb new file mode 100644 index 0000000..e6b24b8 --- /dev/null +++ b/spec/defines/samba__server__share_spec.rb @@ -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 + diff --git a/spec/spec.opts b/spec/spec.opts new file mode 100644 index 0000000..91cd642 --- /dev/null +++ b/spec/spec.opts @@ -0,0 +1,6 @@ +--format +s +--colour +--loadby +mtime +--backtrace diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 81f98ac..ee10669 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,4 +1,7 @@ require 'puppetlabs_spec_helper/module_spec_helper' +require 'rspec-puppet-facts' + +include RspecPuppetFacts RSpec.configure do |c| c.before do -- cgit v1.2.3 From 07fdf27c8c4f0ae710b50bc00b2f5fb0ea0a400e Mon Sep 17 00:00:00 2001 From: Adam Jahn Date: Fri, 8 Jul 2016 15:33:24 -0400 Subject: No need for these files to be exec able --- Gemfile | 0 manifests/server/share.pp | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 Gemfile mode change 100755 => 100644 manifests/server/share.pp (limited to 'Gemfile') diff --git a/Gemfile b/Gemfile old mode 100755 new mode 100644 diff --git a/manifests/server/share.pp b/manifests/server/share.pp old mode 100755 new mode 100644 -- cgit v1.2.3