]> gitweb.fluxo.info Git - puppet-mailalias_core.git/commitdiff
(maint) Update the acceptance tests
authorMelissa Stone <melissa@puppet.com>
Fri, 18 May 2018 18:28:42 +0000 (11:28 -0700)
committerMelissa Stone <melissa@puppet.com>
Fri, 18 May 2018 18:28:44 +0000 (11:28 -0700)
Prior to this commit, the acceptance tests for mailalias were broken up
in a way that was not logical. The tests had been broken up simply
following the 'steps' from the previous iteration. This new structure
did not work, since later steps were dependent on earlier steps. The
tests could not be run in isolation. This commit changes the test set up
so that we can more easily run tests in isolation and in random order.

spec/acceptance/tests/create_spec.rb
spec/acceptance/tests/destroy_spec.rb
spec/acceptance/tests/modify_spec.rb

index 82adfec9121d8940ea9b3476466bcc70cb8cd58b..80fe8d32ad6b89e1cc6ebc58d943d1ea830d4e9a 100644 (file)
@@ -16,13 +16,13 @@ RSpec.context 'Mailalias: should create an email alias' do
   end
 
   non_windows_agents.each do |agent|
-    it 'creates a mailalias with puppet' do
+    it 'creates a mailalias resource' do
+      # create a mailalias with puppet
       args = ['ensure=present',
               'recipient="foo,bar,baz"']
       on(agent, puppet_resource('mailalias', name, args))
-    end
 
-    it 'verifies the alias exists' do
+      # verify the alias exists
       on(agent, 'cat /etc/aliases') do |res|
         assert_match(%r{#{name}:.*foo,bar,baz}, res.stdout, 'mailalias not in aliases file')
       end
index 0f805a504d429170ce1c2630d84a6616ba3bdf7a..a5cb122f25d073740a16bc3d278119e19aee699a 100644 (file)
@@ -1,6 +1,6 @@
 require 'spec_helper_acceptance'
 
-RSpec.context 'should delete an email alias' do
+RSpec.context 'Mailalias: should delete an email alias' do
   name = "pl#{rand(999_999).to_i}"
 
   before(:all) do
@@ -26,13 +26,13 @@ RSpec.context 'should delete an email alias' do
   end
 
   non_windows_agents.each do |agent|
-    it 'deletes the aliases database with puppet' do
+    it 'deletes a mailalias resource' do
+      # delete the aliases database with puppet
       args = ['ensure=absent',
               'recipient="foo,bar,baz"']
       on(agent, puppet_resource('mailalias', name, args))
-    end
 
-    it 'verifies the alias is absent' do
+      # verify the alias is absent
       on(agent, 'cat /etc/aliases') do |res|
         assert_no_match(%r{#{name}:.*foo,bar,baz}, res.stdout, 'mailalias was not removed from aliases file')
       end
index f4ea7bf624d05a9a36ce62dd9b868cd3dd3b70fd..24903b60ee29f20e62fe27b4a03625cfd0f6737c 100644 (file)
@@ -1,11 +1,10 @@
 require 'spec_helper_acceptance'
 
-RSpec.context 'should modify an email alias' do
+RSpec.context 'Mailalias: should modify an email alias' do
   name = "pl#{rand(999_999).to_i}"
 
   before(:all) do
     non_windows_agents.each do |agent|
-      #------- SETUP -------#
       # (setup) backup alias file
       on(agent, 'cp /etc/aliases /tmp/aliases', acceptable_exit_codes: [0, 1])
 
@@ -27,13 +26,13 @@ RSpec.context 'should modify an email alias' do
   end
 
   non_windows_agents.each do |agent|
-    it 'modifies the aliases database with puppet' do
+    it 'modifies an existing mailalias resource' do
+      # modify the aliases database with puppet
       args = ['ensure=present',
               'recipient="foo,bar,baz,blarvitz"']
       on(agent, puppet_resource('mailalias', name, args))
-    end
 
-    it 'verifies the updated alias is present' do
+      # verify the updated alias is present
       on(agent, 'cat /etc/aliases') do |res|
         assert_match(%r{#{name}:.*foo,bar,baz,blarvitz}, res.stdout, 'updated mailalias not in aliases file')
       end