summaryrefslogtreecommitdiffstats
path: root/spec/unit/file_collection.rb
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-04-02 18:56:53 -0500
committerLuke Kanies <luke@madstop.com>2009-04-02 18:56:53 -0500
commit6e79cc00965a50c44f215fd1e553281cfd2b87c9 (patch)
tree56c496df9ad6ab66dfb16993910eb5ff1c34d065 /spec/unit/file_collection.rb
parent62dad7a5f87f8d6285650ab1b727819db27cf2a7 (diff)
parentc62c19370bfba881819c1a3d9da2f8e6fb52e5d9 (diff)
downloadpuppet-6e79cc00965a50c44f215fd1e553281cfd2b87c9.tar.gz
puppet-6e79cc00965a50c44f215fd1e553281cfd2b87c9.tar.xz
puppet-6e79cc00965a50c44f215fd1e553281cfd2b87c9.zip
Merge branch '0.24.x'
Conflicts: bin/ralsh lib/puppet/executables/client/certhandler.rb lib/puppet/parser/functions/versioncmp.rb lib/puppet/parser/resource/reference.rb lib/puppet/provider/augeas/augeas.rb lib/puppet/provider/nameservice/directoryservice.rb lib/puppet/provider/ssh_authorized_key/parsed.rb lib/puppet/type.rb lib/puppet/type/file/checksum.rb spec/integration/defaults.rb spec/integration/transaction/report.rb spec/unit/executables/client/certhandler.rb spec/unit/indirector/ssl_rsa/file.rb spec/unit/node/catalog.rb spec/unit/provider/augeas/augeas.rb spec/unit/rails.rb spec/unit/type/ssh_authorized_key.rb spec/unit/type/tidy.rb test/executables/filebucket.rb test/executables/puppetbin.rb
Diffstat (limited to 'spec/unit/file_collection.rb')
-rwxr-xr-xspec/unit/file_collection.rb53
1 files changed, 53 insertions, 0 deletions
diff --git a/spec/unit/file_collection.rb b/spec/unit/file_collection.rb
new file mode 100755
index 000000000..81bcc2d2d
--- /dev/null
+++ b/spec/unit/file_collection.rb
@@ -0,0 +1,53 @@
+#!/usr/bin/env ruby
+
+require File.dirname(__FILE__) + '/../spec_helper'
+
+require 'puppet/file_collection'
+
+describe Puppet::FileCollection do
+ before do
+ @collection = Puppet::FileCollection.new
+ end
+
+ it "should be able to convert a file name into an index" do
+ @collection.index("/my/file").should be_instance_of(Fixnum)
+ end
+
+ it "should be able to convert an index into a file name" do
+ index = @collection.index("/path/to/file")
+ @collection.path(index).should == "/path/to/file"
+ end
+
+ it "should always give the same file name for a given index" do
+ index = @collection.index("/path/to/file")
+ @collection.path(index).should == @collection.path(index)
+ end
+
+ it "should always give the same index for a given file name" do
+ @collection.index("/my/file").should == @collection.index("/my/file")
+ end
+
+ it "should always correctly relate a file name and its index even when multiple files are in the collection" do
+ indexes = %w{a b c d e f}.inject({}) do |hash, letter|
+ hash[letter] = @collection.index("/path/to/file/%s" % letter)
+ hash
+ end
+
+ indexes.each do |letter, index|
+ @collection.index("/path/to/file/%s" % letter).should == indexes[letter]
+ @collection.path(index).should == @collection.path(index)
+ end
+ end
+
+ it "should return nil as the file name when an unknown index is provided" do
+ @collection.path(50).should be_nil
+ end
+
+ it "should provide a global collection" do
+ Puppet::FileCollection.collection.should be_instance_of(Puppet::FileCollection)
+ end
+
+ it "should reuse the global collection" do
+ Puppet::FileCollection.collection.should equal(Puppet::FileCollection.collection)
+ end
+end