Sha256: 767356fe7d69624b58efd73e284daeba0a123fa6c1ec9f0180a1245b177c8974

Contents?: true

Size: 1.66 KB

Versions: 8

Compression:

Stored size: 1.66 KB

Contents

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

require 'puppet/resource/catalog'

describe "Puppet::Resource::Catalog::Queue" do
  before do
    Puppet::Resource::Catalog.indirection.terminus(:queue)
    @catalog = Puppet::Resource::Catalog.new("foo", Puppet::Node::Environment::NONE)

    @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", @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

8 entries across 8 versions & 1 rubygems

Version Path
puppet-3.6.2 spec/integration/indirector/catalog/queue_spec.rb
puppet-3.6.2-x86-mingw32 spec/integration/indirector/catalog/queue_spec.rb
puppet-3.6.1 spec/integration/indirector/catalog/queue_spec.rb
puppet-3.6.1-x86-mingw32 spec/integration/indirector/catalog/queue_spec.rb
puppet-3.6.0 spec/integration/indirector/catalog/queue_spec.rb
puppet-3.6.0-x86-mingw32 spec/integration/indirector/catalog/queue_spec.rb
puppet-3.6.0.rc1 spec/integration/indirector/catalog/queue_spec.rb
puppet-3.6.0.rc1-x86-mingw32 spec/integration/indirector/catalog/queue_spec.rb