diff options
author | Luke Kanies <luke@madstop.com> | 2009-02-12 23:42:31 -0600 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2009-02-28 09:16:42 +1100 |
commit | 373d505c381696f880c305a9357a6e50342079b8 (patch) | |
tree | 3cc0662af61f698658e9d65971902fac72e4272d /spec/unit/file_collection.rb | |
parent | 0e467869f4d427a8c42e1c2ff6a0bb215f288b09 (diff) | |
download | puppet-373d505c381696f880c305a9357a6e50342079b8.tar.gz puppet-373d505c381696f880c305a9357a6e50342079b8.tar.xz puppet-373d505c381696f880c305a9357a6e50342079b8.zip |
Adding a FileCollection and a lookup module for it.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec/unit/file_collection.rb')
-rwxr-xr-x | spec/unit/file_collection.rb | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/spec/unit/file_collection.rb b/spec/unit/file_collection.rb new file mode 100755 index 000000000..e9acc8dd2 --- /dev/null +++ b/spec/unit/file_collection.rb @@ -0,0 +1,45 @@ +#!/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 +end |