diff options
| author | Luke Kanies <luke@madstop.com> | 2007-10-19 17:35:40 -0500 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2007-10-19 17:35:40 -0500 |
| commit | 08099b7a383987e292357f285e05933e10205660 (patch) | |
| tree | c8f08a3afca5c9b45f965c7c8d051023170ea0d5 /spec/unit/indirector/file_metadata | |
| parent | ec396729d76b26d0d08c0bd633f28fa3c68c414c (diff) | |
| download | puppet-08099b7a383987e292357f285e05933e10205660.tar.gz puppet-08099b7a383987e292357f285e05933e10205660.tar.xz puppet-08099b7a383987e292357f285e05933e10205660.zip | |
File serving now works. I've tested a couple of ways to
use it, and added integration tests at the most important
hook points.
This provides the final class structure for all of these classes,
but a lot of the class names are pretty bad, so I'm planning on
going through all of them (especially the file_server stuff) and
renaming.
The functionality is all here for finding files, though (finally).
Once the classes are renamed, I'll be adding searching ability
(which will enable the recursive file copies) and then adding
the link management and enabling ignoring files.
Diffstat (limited to 'spec/unit/indirector/file_metadata')
| -rwxr-xr-x | spec/unit/indirector/file_metadata/modules.rb | 40 | ||||
| -rwxr-xr-x | spec/unit/indirector/file_metadata/mounts.rb | 40 |
2 files changed, 42 insertions, 38 deletions
diff --git a/spec/unit/indirector/file_metadata/modules.rb b/spec/unit/indirector/file_metadata/modules.rb new file mode 100755 index 000000000..94e1bf0dc --- /dev/null +++ b/spec/unit/indirector/file_metadata/modules.rb @@ -0,0 +1,40 @@ +#!/usr/bin/env ruby +# +# Created by Luke Kanies on 2007-10-18. +# Copyright (c) 2007. All rights reserved. + +require File.dirname(__FILE__) + '/../../../spec_helper' + +require 'puppet/indirector/file_metadata/modules' + +describe Puppet::Indirector::FileMetadata::Modules do + it "should be registered with the file_metadata indirection" do + Puppet::Indirector::Terminus.terminus_class(:file_metadata, :modules).should equal(Puppet::Indirector::FileMetadata::Modules) + end + + it "should be a subclass of the ModuleFiles terminus" do + Puppet::Indirector::FileMetadata::Modules.superclass.should equal(Puppet::Indirector::ModuleFiles) + end +end + +describe Puppet::Indirector::FileMetadata::Modules, " when finding metadata" do + before do + @finder = Puppet::Indirector::FileMetadata::Modules.new + @finder.stubs(:environment).returns(nil) + @module = Puppet::Module.new("mymod", "/path/to") + @finder.stubs(:find_module).returns(@module) + end + + it "should return nil if the file is not found" do + FileTest.expects(:exists?).with("/path/to/files/my/file").returns false + @finder.find("puppetmounts://hostname/modules/mymod/my/file").should be_nil + end + + it "should retrieve the instance's attributes if the file is found" do + FileTest.expects(:exists?).with("/path/to/files/my/file").returns true + instance = mock 'metadta' + Puppet::FileServing::Metadata.expects(:new).returns instance + instance.expects :get_attributes + @finder.find("puppetmounts://hostname/modules/mymod/my/file") + end +end diff --git a/spec/unit/indirector/file_metadata/mounts.rb b/spec/unit/indirector/file_metadata/mounts.rb index 558e920ee..33f977163 100755 --- a/spec/unit/indirector/file_metadata/mounts.rb +++ b/spec/unit/indirector/file_metadata/mounts.rb @@ -12,43 +12,7 @@ describe Puppet::Indirector::FileMetadata::Mounts do Puppet::Indirector::Terminus.terminus_class(:file_metadata, :mounts).should equal(Puppet::Indirector::FileMetadata::Mounts) end - it "should be a subclass of the Code terminus" do - Puppet::Indirector::FileMetadata::Mounts.superclass.should equal(Puppet::Indirector::Code) + it "should be a subclass of the FileServer terminus" do + Puppet::Indirector::FileMetadata::Mounts.superclass.should equal(Puppet::Indirector::FileServer) end end - -describe Puppet::Indirector::FileMetadata::Mounts, "when finding a single file" do - before do - @metadata = Puppet::Indirector::FileMetadata::Mounts.new - @uri = "puppetmounts://host/my/local" - end - - it "should use the path portion of the URI as the file name" do - Puppet::FileServing::Configuration.create.expects(:file_path).with("/my/local") - @metadata.find(@uri) - end - - it "should use the FileServing configuration to convert the file name to a fully qualified path" do - Puppet::FileServing::Configuration.create.expects(:file_path).with("/my/local") - @metadata.find(@uri) - end - - it "should return nil if no fully qualified path is found" do - Puppet::FileServing::Configuration.create.expects(:file_path).with("/my/local").returns(nil) - @metadata.find(@uri).should be_nil - end - - it "should return nil if the configuration returns a file path that does not exist" do - Puppet::FileServing::Configuration.create.expects(:file_path).with("/my/local").returns("/some/file") - FileTest.expects(:exists?).with("/some/file").returns(false) - @metadata.find(@uri).should be_nil - end - - it "should return a Metadata instance if a file is found and it exists" do - Puppet::FileServing::Configuration.create.expects(:file_path).with("/my/local").returns("/some/file") - FileTest.expects(:exists?).with("/some/file").returns(true) - Puppet::FileServing::Metadata.expects(:new).with("/some/file").returns(:mymetadata) - @metadata.find(@uri).should == :mymetadata - end -end - |
