Sha256: b32543e15ce60f54ea29188ca09a920bd9c6712d863c9e411833d3dc37f06f02

Contents?: true

Size: 1.81 KB

Versions: 72

Compression:

Stored size: 1.81 KB

Contents

require 'spec_helper'
require 'puppet/graph'

describe Puppet::Graph::TitleHashPrioritizer do
  it "produces different priorities for different resource references" do
    prioritizer = Puppet::Graph::TitleHashPrioritizer.new

    expect(prioritizer.generate_priority_for(resource(:notify, "one"))).to_not(
      eq(prioritizer.generate_priority_for(resource(:notify, "two"))))
  end

  it "always produces the same priority for the same resource ref" do
    a_prioritizer = Puppet::Graph::TitleHashPrioritizer.new
    another_prioritizer = Puppet::Graph::TitleHashPrioritizer.new

    expect(a_prioritizer.generate_priority_for(resource(:notify, "one"))).to(
      eq(another_prioritizer.generate_priority_for(resource(:notify, "one"))))
  end

  it "does not use the container when generating priorities" do
    prioritizer = Puppet::Graph::TitleHashPrioritizer.new

    expect(prioritizer.generate_priority_contained_in(nil, resource(:notify, "one"))).to(
      eq(prioritizer.generate_priority_for(resource(:notify, "one"))))
  end

  it "can retrieve a previously provided priority with the same resource" do
    prioritizer = Puppet::Graph::TitleHashPrioritizer.new
    resource = resource(:notify, "title")

    generated = prioritizer.generate_priority_for(resource)

    expect(prioritizer.priority_of(resource)).to eq(generated)
  end

  it "can not retrieve the priority of a resource with a different resource with the same title" do
    prioritizer = Puppet::Graph::TitleHashPrioritizer.new
    resource = resource(:notify, "title")
    different_resource = resource(:notify, "title")

    prioritizer.generate_priority_for(resource)

    expect(prioritizer.priority_of(resource)).not_to be_nil
    expect(prioritizer.priority_of(different_resource)).to be_nil
  end

  def resource(type, title)
    Puppet::Resource.new(type, title)
  end
end

Version data entries

72 entries across 72 versions & 1 rubygems

Version Path
puppet-5.5.22 spec/unit/graph/title_hash_prioritizer_spec.rb
puppet-5.5.22-x86-mingw32 spec/unit/graph/title_hash_prioritizer_spec.rb
puppet-5.5.22-x64-mingw32 spec/unit/graph/title_hash_prioritizer_spec.rb
puppet-5.5.22-universal-darwin spec/unit/graph/title_hash_prioritizer_spec.rb
puppet-5.5.21 spec/unit/graph/title_hash_prioritizer_spec.rb
puppet-5.5.21-x86-mingw32 spec/unit/graph/title_hash_prioritizer_spec.rb
puppet-5.5.21-x64-mingw32 spec/unit/graph/title_hash_prioritizer_spec.rb
puppet-5.5.21-universal-darwin spec/unit/graph/title_hash_prioritizer_spec.rb
puppet-5.5.20 spec/unit/graph/title_hash_prioritizer_spec.rb
puppet-5.5.20-x86-mingw32 spec/unit/graph/title_hash_prioritizer_spec.rb
puppet-5.5.20-x64-mingw32 spec/unit/graph/title_hash_prioritizer_spec.rb
puppet-5.5.20-universal-darwin spec/unit/graph/title_hash_prioritizer_spec.rb
puppet-5.5.19 spec/unit/graph/title_hash_prioritizer_spec.rb
puppet-5.5.19-x86-mingw32 spec/unit/graph/title_hash_prioritizer_spec.rb
puppet-5.5.19-x64-mingw32 spec/unit/graph/title_hash_prioritizer_spec.rb
puppet-5.5.19-universal-darwin spec/unit/graph/title_hash_prioritizer_spec.rb
puppet-5.5.18 spec/unit/graph/title_hash_prioritizer_spec.rb
puppet-5.5.18-x86-mingw32 spec/unit/graph/title_hash_prioritizer_spec.rb
puppet-5.5.18-x64-mingw32 spec/unit/graph/title_hash_prioritizer_spec.rb
puppet-5.5.18-universal-darwin spec/unit/graph/title_hash_prioritizer_spec.rb