Sha256: 512151f061e9267435dfc347881e318f93cfb54b66a695e3f17511505c758793

Contents?: true

Size: 1.67 KB

Versions: 6

Compression:

Stored size: 1.67 KB

Contents

#!/usr/bin/env rspec
require 'spec_helper'

require 'puppet/resource/catalog'

describe "Puppet::Resource::Catalog::Queue", :if => Puppet.features.pson? do
  before do
    Puppet::Resource::Catalog.indirection.terminus(:queue)
    @catalog = Puppet::Resource::Catalog.new("foo")

    @one = Puppet::Resource.new(:file, "/one")
    @two = Puppet::Resource.new(:file, "/two")
    @catalog.add_resource(@one, @two)

    @catalog.add_edge(@one, @two)

    Puppet[:trace] = true
  end

  after { Puppet.settings.clear }

  it "should render catalogs to pson and publish them via the queue client when catalogs are saved" do
    terminus = Puppet::Resource::Catalog.indirection.terminus(:queue)

    client = mock 'client'
    terminus.stubs(:client).returns client

    client.expects(:publish_message).with(:catalog, @catalog.to_pson)

    request = Puppet::Indirector::Request.new(:catalog, :save, "foo", :instance => @catalog)

    terminus.save(request)
  end

  it "should intern catalog messages when they are passed via a subscription" do
    client = mock 'client'
    Puppet::Resource::Catalog::Queue.stubs(:client).returns client

    pson = @catalog.to_pson

    client.expects(:subscribe).with(:catalog).yields(pson)

    Puppet.expects(:err).never

    result = []
    Puppet::Resource::Catalog::Queue.subscribe do |catalog|
      result << catalog
    end

    catalog = result.shift
    catalog.should be_instance_of(Puppet::Resource::Catalog)

    catalog.resource(:file, "/one").should be_instance_of(Puppet::Resource)
    catalog.resource(:file, "/two").should be_instance_of(Puppet::Resource)
    catalog.should be_edge(catalog.resource(:file, "/one"), catalog.resource(:file, "/two"))
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
puppet-2.7.26 spec/integration/indirector/catalog/queue_spec.rb
puppet-2.7.25 spec/integration/indirector/catalog/queue_spec.rb
puppet-2.7.24 spec/integration/indirector/catalog/queue_spec.rb
puppet-2.7.23 spec/integration/indirector/catalog/queue_spec.rb
puppet-2.7.22 spec/integration/indirector/catalog/queue_spec.rb
puppet-2.7.21 spec/integration/indirector/catalog/queue_spec.rb