File: test_failure.rb

package info (click to toggle)
ruby-puppet-resource-api 1.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,232 kB
  • sloc: ruby: 9,573; sh: 4; makefile: 2
file content (24 lines) | stat: -rw-r--r-- 593 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
require 'puppet/resource_api'
require 'puppet/resource_api/simple_provider'

# Implementation for the test_bool type using the Resource API.
class Puppet::Provider::TestFailure::TestFailure
  def get(_context)
    []
  end

  def set(context, changes)
    changes.each do |name, change|
      is = change[:is]
      should = change[:should]

      context.notice(name, "Creating '#{name}' with #{should.inspect}")
      if should[:failure]
        context.creating(name) do
          raise "A failure for #{name}"
        end
      end
      context.notice(name, "Finished")
    end
  end
end