File: should_run_command.rb

package info (click to toggle)
puppet-agent 8.10.0-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 27,404 kB
  • sloc: ruby: 286,820; sh: 492; xml: 116; makefile: 88; cs: 68
file content (35 lines) | stat: -rw-r--r-- 1,068 bytes parent folder | download | duplicates (2)
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
35
test_name "tests that puppet correctly runs an exec."
# original author: Dan Bode  --daniel 2010-12-23

tag 'audit:high',
    'audit:refactor',   # Use block style `test_name`
    'audit:acceptance'

def before(agent)
  step "file to be touched should not exist."
  agent.tmpfile('test-exec')
end

def after(agent, touched)
  step "checking the output worked"
  on agent, "test -f #{touched}"

  step "clean up the system"
  on agent, "rm -f #{touched}"
end

agents.each do |agent|
  touched = before(agent)
  apply_manifest_on(agent, "exec {'test': command=>'#{agent.touch(touched)}'}") do |result|
    fail_test "didn't seem to run the command" unless
      result.stdout.include? 'executed successfully' unless agent['locale'] == 'ja'
  end
  after(agent, touched)

  touched = before(agent)
  on(agent, puppet_resource('-d', 'exec', 'test', "command='#{agent.touch(touched)}'}")) do |result|
    fail_test "didn't seem to run the command" unless
      result.stdout.include? 'executed successfully' unless agent['locale'] == 'ja'
  end
  after(agent, touched)
end