From 4691b3929d0f079b8152cc5e73496c1ae48237eb Mon Sep 17 00:00:00 2001 From: Dan Bode Date: Mon, 23 Jul 2012 15:04:14 -0700 Subject: [PATCH] Add spec tests for additional loopback parameter. This commit adds test coverage that verifies the behavior of the loopback related class parameters. --- spec/defines/swift_storage_loopback_spec.rb | 18 ++++++++-- spec/defines/swift_storage_mount_spec.rb | 40 ++++++++++++++++++++- spec/defines/swift_storage_xfs_spec.rb | 21 +++++++---- spec/fixtures/modules/swift | 1 - 4 files changed, 69 insertions(+), 11 deletions(-) delete mode 120000 spec/fixtures/modules/swift diff --git a/spec/defines/swift_storage_loopback_spec.rb b/spec/defines/swift_storage_loopback_spec.rb index feb75c94..8e1f125b 100644 --- a/spec/defines/swift_storage_loopback_spec.rb +++ b/spec/defines/swift_storage_loopback_spec.rb @@ -1,4 +1,18 @@ +require 'spec_helper' + describe 'swift::storage::loopback' do - # TODO add unit tests - # this is not the highest priority b/c it is really for testing + # TODO add more unit tests + + let :title do + 'dans_disk' + end + + it { should contain_swift__storage__xfs('dans_disk').with( + :device => '/srv/loopback-device/dans_disk', + :mnt_base_dir => '/srv/node', + :byte_size => '1024', + :subscribe => 'Exec[create_partition-dans_disk]', + :loopback => true + ) } + end diff --git a/spec/defines/swift_storage_mount_spec.rb b/spec/defines/swift_storage_mount_spec.rb index 95ac9afc..1feccd9d 100644 --- a/spec/defines/swift_storage_mount_spec.rb +++ b/spec/defines/swift_storage_mount_spec.rb @@ -1,4 +1,42 @@ +require 'spec_helper' describe 'swift::storage::mount' do # TODO add unit tests - # not a super high priority b/c this is just for testing + + let :title do + 'dans_mount_point' + end + + describe 'with defaults params' do + let :params do + { + :device => '/dev/sda' + } + end + + it { should contain_mount('/srv/node/dans_mount_point').with( + :ensure => 'present', + :device => '/dev/sda', + :fstype => 'xfs', + :options => 'noatime,nodiratime,nobarrier,logbufs=8', + :require => 'File[/srv/node/dans_mount_point]' + )} + + end + + describe 'when mounting a loopback device' do + + let :params do + { + :device => '/dev/sda', + :loopback => true + } + end + + it { should contain_mount('/srv/node/dans_mount_point').with( + :device => '/dev/sda', + :options => 'noatime,nodiratime,nobarrier,logbufs=8,loop' + )} + + end + end diff --git a/spec/defines/swift_storage_xfs_spec.rb b/spec/defines/swift_storage_xfs_spec.rb index d395673c..a7892bda 100644 --- a/spec/defines/swift_storage_xfs_spec.rb +++ b/spec/defines/swift_storage_xfs_spec.rb @@ -13,15 +13,21 @@ describe 'swift::storage::xfs' do describe 'when a device is specified' do let :default_params do - {:device => 'some_device', + { + :device => 'some_device', :byte_size => '1024', - :mnt_base_dir => '/srv/node'} + :mnt_base_dir => '/srv/node', + :loopback => false + } end [{:device => 'some_device'}, - {:device => 'some_device', - :byte_size => 1, - :mnt_base_dir => '/mnt/foo'} + { + :device => 'some_device', + :byte_size => 1, + :mnt_base_dir => '/mnt/foo', + :loopback => true + } ].each do |param_set| describe "#{param_set == {} ? "using default" : "specifying"} class parameters" do @@ -41,9 +47,10 @@ describe 'swift::storage::xfs' do )} it { should contain_swift__storage__mount('foo').with( - {:device => param_hash[:device], + :device => param_hash[:device], :mnt_base_dir => param_hash[:mnt_base_dir], - :subscribe => 'Exec[mkfs-foo]'} + :loopback => param_hash[:loopback], + :subscribe => 'Exec[mkfs-foo]' )} end diff --git a/spec/fixtures/modules/swift b/spec/fixtures/modules/swift deleted file mode 120000 index 1b20c9fb..00000000 --- a/spec/fixtures/modules/swift +++ /dev/null @@ -1 +0,0 @@ -../../../ \ No newline at end of file