aboutsummaryrefslogtreecommitdiff
path: root/spec/acceptance/tests/resource/cron/should_be_idempotent_spec.rb
blob: 4bf515eb0d8b7eb98eb61db7c36426d3193b3067 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
require 'spec_helper_acceptance'

RSpec.context 'when checking idempotency' do
  before(:each) do
    compatible_agents.each do |agent|
      step 'ensure the user exists via puppet'
      setup(agent)
    end
  end

  after(:each) do
    compatible_agents.each do |agent|
      step 'Cron: cleanup'
      clean(agent)
    end
  end

  compatible_agents.each do |agent|
    it "ensures idempotency on #{agent}" do
      step 'Cron: basic - verify that it can be created'
      apply_manifest_on(agent, 'cron { "myjob": command => "/bin/true", user    => "tstuser", hour    => "*", minute  => [1], ensure  => present,}') do
        expect(@result.stdout).to match(%r{ensure: created})
      end
      run_cron_on(agent, :list, 'tstuser') do
        expect(@result.stdout).to match(%r{. . . . . .bin.true})
      end

      step 'Cron: basic - should not create again'
      apply_manifest_on(agent, 'cron { "myjob": command => "/bin/true", user    => "tstuser", hour    => "*", minute  => [1], ensure  => present,}') do
        expect(@result.stdout).not_to match(%r{ensure: created})
      end
    end
  end
end