~ubuntu-branches/ubuntu/lucid/puppet/lucid-security

« back to all changes in this revision

Viewing changes to test/ral/providers/provider.rb

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2009-12-23 00:48:10 UTC
  • mfrom: (1.1.10 upstream) (3.1.7 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091223004810-3i4oryds922g5n59
Tags: 0.25.1-3ubuntu1
* Merge from debian testing.  Remaining changes:
  - debian/rules:
    + Don't start puppet when first installing puppet.
  - debian/puppet.conf, lib/puppet/defaults.rb:
    + Move templates to /etc/puppet
  - lib/puppet/defaults.rb:
    + Fix /var/lib/puppet/state ownership.
  - man/man8/puppet.conf.8: 
    + Fix broken URL in manpage.
  - debian/control:
    + Update maintainer accordint to spec.
    + Puppetmaster Recommends -> Suggests
    + Created puppet-testsuite as a seperate. Allow the users to run puppet's 
      testsuite.
  - tests/Rakefile: Fix rakefile so that the testsuite can acutally be ran.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
require 'facter'
7
7
 
8
8
class TestProvider < Test::Unit::TestCase
9
 
        include PuppetTest
 
9
    include PuppetTest
10
10
 
11
11
    def echo
12
12
        echo = Puppet::Util.binary("echo")
319
319
    def test_initialize
320
320
        test = @type.provide(:test)
321
321
 
322
 
        inst = @type.create :name => "boo"
 
322
        inst = @type.new :name => "boo"
323
323
        prov = nil
324
324
        assert_nothing_raised("Could not init with a resource") do
325
325
            prov = test.new(inst)
345
345
end
346
346
 
347
347
class TestProviderFeatures < Test::Unit::TestCase
348
 
        include PuppetTest
 
348
    include PuppetTest
349
349
 
350
350
    def setup
351
351
        super
381
381
            end
382
382
        end
383
383
 
384
 
        resource = @type.create(:name => "foo")
 
384
        resource = @type.new(:name => "foo")
385
385
        {:numbers => [:numeric], :letters => [:alpha], :both => [:numeric, :alpha],
386
386
            :mixed => [], :neither => []}.each do |name, should|
387
387
                should.sort! { |a,b| a.to_s <=> b.to_s }
453
453
            define_method(:one) {}
454
454
            define_method(:two) {}
455
455
        end
456
 
        
 
456
 
457
457
        # Another with the numbers and a declaration
458
458
        @type.provide(:both) do
459
459
            define_method(:one) {}
461
461
 
462
462
            has_feature :alpha
463
463
        end
464
 
        
 
464
 
465
465
        # And just the declaration
466
466
        @type.provide(:letters) do
467
467
            has_feature :alpha
484
484
            features.sort! { |a,b| a.to_s <=> b.to_s }
485
485
            assert_equal(features, provider.features, "Got incorrect feature list for provider instance %s" % name)
486
486
            assert_equal(features, provider_class.features, "Got incorrect feature list for provider class %s" % name)
487
 
            features.each do |feat| 
 
487
            features.each do |feat|
488
488
                assert(provider.feature?(feat), "Provider instance %s did not have feature %s" % [name, feat])
489
489
                assert(provider_class.feature?(feat), "Provider class %s did not have feature %s" % [name, feat])
490
490
            end
506
506
        [nope, maybe, yep].each do |prov|
507
507
            assert(prov.respond_to?(:supports_parameter?), "%s does not respond to :supports_parameter?" % prov.name)
508
508
            case prov.name
509
 
            when :nope:
 
509
            when :nope
510
510
                supported = [:neither]
511
511
                un = [:some, :both]
512
 
            when :maybe:
 
512
            when :maybe
513
513
                supported = [:neither, :some]
514
514
                un = [:both]
515
 
            when :yep:
 
515
            when :yep
516
516
                supported = [:neither, :some, :both]
517
517
                un = []
518
518
            end