Sha256: 3d8c964733ffb6c41171fd59ecabeb2f024a22bc954f127b6f705073158414cd

Contents?: true

Size: 1.51 KB

Versions: 35

Compression:

Stored size: 1.51 KB

Contents

#!/usr/bin/env ruby

require File.expand_path(File.dirname(__FILE__) + '/../lib/puppettest')

require 'puppet'
require 'puppettest'

class TestStorage < Test::Unit::TestCase
  include PuppetTest

  def mkfile
    path = tempfile
    File.open(path, "w") { |f| f.puts :yayness }


          f = Puppet::Type.type(:file).new(
                
      :name => path,
        
      :check => %w{checksum type}
    )

    f
  end

  def test_storeandretrieve
    path = tempfile

    f = mkfile

    # Load first, since that's what we do in the code base; this creates
    # all of the necessary directories.
    assert_nothing_raised {
      Puppet::Util::Storage.load
    }

    hash = {:a => :b, :c => :d}

    state = nil
    assert_nothing_raised {
      state = Puppet::Util::Storage.cache(f)
    }

    assert(!state.include?("name"))

    assert_nothing_raised {
      state["name"] = hash
    }

    assert_nothing_raised {
      Puppet::Util::Storage.store
    }
    assert_nothing_raised {
      Puppet::Util::Storage.clear
    }
    assert_nothing_raised {
      Puppet::Util::Storage.load
    }

    # Reset it
    state = nil
    assert_nothing_raised {
      state = Puppet::Util::Storage.cache(f)
    }

    assert_equal(state["name"], hash)
  end

  def test_emptyrestore
    Puppet::Util::Storage.load
    Puppet::Util::Storage.store
    Puppet::Util::Storage.clear
    Puppet::Util::Storage.load

    f = mkfile
    state = Puppet::Util::Storage.cache(f)
    assert_same Hash, state.class
    assert_equal 0, state.size
  end
end

Version data entries

35 entries across 35 versions & 3 rubygems

Version Path
puppet-2.7.26 test/util/storage.rb
puppet-2.7.25 test/util/storage.rb
puppet-2.7.24 test/util/storage.rb
puppet-2.7.23 test/util/storage.rb
puppet-2.7.22 test/util/storage.rb
puppet-2.7.21 test/util/storage.rb
puppet-2.7.20 test/util/storage.rb
puppet-2.7.20.rc1 test/util/storage.rb
librarian-puppet-0.9.4 vendor/gems/ruby/1.8/gems/puppet-2.7.18/test/util/storage.rb
puppet-2.7.19 test/util/storage.rb
supply_drop-0.11.0 examples/vendored-puppet/vendor/puppet-2.7.8/test/util/storage.rb
librarian-puppet-0.9.3 vendor/gems/ruby/1.8/gems/puppet-2.7.18/test/util/storage.rb
supply_drop-0.10.2 examples/vendored-puppet/vendor/puppet-2.7.8/test/util/storage.rb
puppet-2.7.18 test/util/storage.rb
supply_drop-0.10.1 examples/vendored-puppet/vendor/puppet-2.7.8/test/util/storage.rb
supply_drop-0.10.0 examples/vendored-puppet/vendor/puppet-2.7.8/test/util/storage.rb
puppet-2.7.17 test/util/storage.rb
puppet-2.7.16 test/util/storage.rb
puppet-2.7.14 test/util/storage.rb
puppet-2.7.13 test/util/storage.rb