From de5d91e2036de2934a4eec79d35a714f3ed24b10 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Mon, 22 Oct 2007 22:37:52 -0500 Subject: Renaming the :local termini for metadata and content to :file. --- spec/unit/file_serving/terminus_selector.rb | 14 ++--- spec/unit/indirector/file_content/file.rb | 70 ++++++++++++++++++++++++ spec/unit/indirector/file_content/local.rb | 70 ------------------------ spec/unit/indirector/file_metadata/file.rb | 82 +++++++++++++++++++++++++++++ spec/unit/indirector/file_metadata/local.rb | 82 ----------------------------- 5 files changed, 159 insertions(+), 159 deletions(-) create mode 100755 spec/unit/indirector/file_content/file.rb delete mode 100755 spec/unit/indirector/file_content/local.rb create mode 100755 spec/unit/indirector/file_metadata/file.rb delete mode 100755 spec/unit/indirector/file_metadata/local.rb (limited to 'spec/unit') diff --git a/spec/unit/file_serving/terminus_selector.rb b/spec/unit/file_serving/terminus_selector.rb index 046f71bdc..9c2c01bfd 100755 --- a/spec/unit/file_serving/terminus_selector.rb +++ b/spec/unit/file_serving/terminus_selector.rb @@ -65,17 +65,17 @@ describe Puppet::FileServing::TerminusSelector, " when being used to select term @object.select_terminus("puppet:///module/file").should == :rest end - it "should choose :local when the protocol is 'file'" do - @object.select_terminus("file://host/module/file").should == :local + it "should choose :file when the protocol is 'file'" do + @object.select_terminus("file://host/module/file").should == :file end - it "should choose :local when the URI is a normal path name" do - @object.select_terminus("/module/file").should == :local + it "should choose :file when the URI is a normal path name" do + @object.select_terminus("/module/file").should == :file end - # This is so that we only choose modules over mounts, not local - it "should choose :local when the protocol is 'file' and the fully qualified path starts with '/modules'" do - @object.select_terminus("file://host/modules/file").should == :local + # This is so that we only choose modules over mounts, not file + it "should choose :file when the protocol is 'file' and the fully qualified path starts with '/modules'" do + @object.select_terminus("file://host/modules/file").should == :file end it "should fail when a protocol other than :puppet, :file, or :puppetmounts is used" do diff --git a/spec/unit/indirector/file_content/file.rb b/spec/unit/indirector/file_content/file.rb new file mode 100755 index 000000000..da2c90770 --- /dev/null +++ b/spec/unit/indirector/file_content/file.rb @@ -0,0 +1,70 @@ +#!/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_content/file' + +describe Puppet::Indirector::FileContent::File do + it "should be registered with the file_content indirection" do + Puppet::Indirector::Terminus.terminus_class(:file_content, :file).should equal(Puppet::Indirector::FileContent::File) + end + + it "should be a subclass of the File terminus" do + Puppet::Indirector::FileContent::File.superclass.should equal(Puppet::Indirector::File) + end +end + +describe Puppet::Indirector::FileContent::File, "when finding a single file" do + it "should return a Content instance created with the full path to the file if the file exists" do + @content = Puppet::Indirector::FileContent::File.new + @uri = "file:///my/local" + + FileTest.expects(:exists?).with("/my/local").returns true + Puppet::FileServing::Content.expects(:new).with("/my/local", :links => nil).returns(:mycontent) + @content.find(@uri).should == :mycontent + end + + it "should pass the :links setting on to the created Content instance if the file exists" do + @content = Puppet::Indirector::FileContent::File.new + @uri = "file:///my/local" + + FileTest.expects(:exists?).with("/my/local").returns true + Puppet::FileServing::Content.expects(:new).with("/my/local", :links => :manage).returns(:mycontent) + @content.find(@uri, :links => :manage) + end + + it "should return nil if the file does not exist" do + @content = Puppet::Indirector::FileContent::File.new + @uri = "file:///my/local" + + FileTest.expects(:exists?).with("/my/local").returns false + @content.find(@uri).should be_nil + end +end + +describe Puppet::Indirector::FileContent::File, "when searching for multiple files" do + before do + @content = Puppet::Indirector::FileContent::File.new + @uri = "file:///my/local" + end + + it "should return nil if the file does not exist" do + FileTest.expects(:exists?).with("/my/local").returns false + @content.find(@uri).should be_nil + end + + it "should use :path2instances from the terminus_helper to return instances if the file exists" do + FileTest.expects(:exists?).with("/my/local").returns true + @content.expects(:path2instances).with("/my/local", {}) + @content.search(@uri) + end + + it "should pass any options on to :path2instances" do + FileTest.expects(:exists?).with("/my/local").returns true + @content.expects(:path2instances).with("/my/local", :testing => :one, :other => :two) + @content.search(@uri, :testing => :one, :other => :two) + end +end diff --git a/spec/unit/indirector/file_content/local.rb b/spec/unit/indirector/file_content/local.rb deleted file mode 100755 index 442667518..000000000 --- a/spec/unit/indirector/file_content/local.rb +++ /dev/null @@ -1,70 +0,0 @@ -#!/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_content/local' - -describe Puppet::Indirector::FileContent::Local do - it "should be registered with the file_content indirection" do - Puppet::Indirector::Terminus.terminus_class(:file_content, :local).should equal(Puppet::Indirector::FileContent::Local) - end - - it "should be a subclass of the File terminus" do - Puppet::Indirector::FileContent::Local.superclass.should equal(Puppet::Indirector::File) - end -end - -describe Puppet::Indirector::FileContent::Local, "when finding a single file" do - it "should return a Content instance created with the full path to the file if the file exists" do - @content = Puppet::Indirector::FileContent::Local.new - @uri = "file:///my/local" - - FileTest.expects(:exists?).with("/my/local").returns true - Puppet::FileServing::Content.expects(:new).with("/my/local", :links => nil).returns(:mycontent) - @content.find(@uri).should == :mycontent - end - - it "should pass the :links setting on to the created Content instance if the file exists" do - @content = Puppet::Indirector::FileContent::Local.new - @uri = "file:///my/local" - - FileTest.expects(:exists?).with("/my/local").returns true - Puppet::FileServing::Content.expects(:new).with("/my/local", :links => :manage).returns(:mycontent) - @content.find(@uri, :links => :manage) - end - - it "should return nil if the file does not exist" do - @content = Puppet::Indirector::FileContent::Local.new - @uri = "file:///my/local" - - FileTest.expects(:exists?).with("/my/local").returns false - @content.find(@uri).should be_nil - end -end - -describe Puppet::Indirector::FileContent::Local, "when searching for multiple files" do - before do - @content = Puppet::Indirector::FileContent::Local.new - @uri = "file:///my/local" - end - - it "should return nil if the file does not exist" do - FileTest.expects(:exists?).with("/my/local").returns false - @content.find(@uri).should be_nil - end - - it "should use :path2instances from the terminus_helper to return instances if the file exists" do - FileTest.expects(:exists?).with("/my/local").returns true - @content.expects(:path2instances).with("/my/local", {}) - @content.search(@uri) - end - - it "should pass any options on to :path2instances" do - FileTest.expects(:exists?).with("/my/local").returns true - @content.expects(:path2instances).with("/my/local", :testing => :one, :other => :two) - @content.search(@uri, :testing => :one, :other => :two) - end -end diff --git a/spec/unit/indirector/file_metadata/file.rb b/spec/unit/indirector/file_metadata/file.rb new file mode 100755 index 000000000..c88d559a7 --- /dev/null +++ b/spec/unit/indirector/file_metadata/file.rb @@ -0,0 +1,82 @@ +#!/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/file' + +describe Puppet::Indirector::FileMetadata::File do + it "should be registered with the file_metadata indirection" do + Puppet::Indirector::Terminus.terminus_class(:file_metadata, :file).should equal(Puppet::Indirector::FileMetadata::File) + end +end + +describe Puppet::Indirector::FileMetadata::File, "when finding a single file" do + before do + @metadata = Puppet::Indirector::FileMetadata::File.new + @uri = "file:///my/local" + + @data = mock 'metadata' + end + + it "should return a Metadata instance created with the full path to the file if the file exists" do + @data.stubs(:collect_attributes) + + FileTest.expects(:exists?).with("/my/local").returns true + Puppet::FileServing::Metadata.expects(:new).with("/my/local", :links => nil).returns(@data) + @metadata.find(@uri).should == @data + end + + it "should pass the :links setting on to the created Content instance if the file exists" do + @data.stubs(:collect_attributes) + + FileTest.expects(:exists?).with("/my/local").returns true + Puppet::FileServing::Metadata.expects(:new).with("/my/local", :links => :manage).returns(@data) + @metadata.find(@uri, :links => :manage) + end + + it "should collect its attributes when a file is found" do + @data.expects(:collect_attributes) + + FileTest.expects(:exists?).with("/my/local").returns true + Puppet::FileServing::Metadata.expects(:new).with("/my/local", :links => nil).returns(@data) + @metadata.find(@uri).should == @data + end + + it "should return nil if the file does not exist" do + FileTest.expects(:exists?).with("/my/local").returns false + @metadata.find(@uri).should be_nil + end +end + +describe Puppet::Indirector::FileMetadata::File, "when searching for multiple files" do + before do + @metadata = Puppet::Indirector::FileMetadata::File.new + @uri = "file:///my/local" + end + + it "should return nil if the file does not exist" do + FileTest.expects(:exists?).with("/my/local").returns false + @metadata.find(@uri).should be_nil + end + + it "should use :path2instances from the terminus_helper to return instances if the file exists" do + FileTest.expects(:exists?).with("/my/local").returns true + @metadata.expects(:path2instances).with("/my/local", {}).returns([]) + @metadata.search(@uri) + end + + it "should pass any options on to :path2instances" do + FileTest.expects(:exists?).with("/my/local").returns true + @metadata.expects(:path2instances).with("/my/local", :testing => :one, :other => :two).returns([]) + @metadata.search(@uri, :testing => :one, :other => :two) + end + + it "should collect the attributes of the instances returned" do + FileTest.expects(:exists?).with("/my/local").returns true + @metadata.expects(:path2instances).with("/my/local", {}).returns( [mock("one", :collect_attributes => nil), mock("two", :collect_attributes => nil)] ) + @metadata.search(@uri) + end +end diff --git a/spec/unit/indirector/file_metadata/local.rb b/spec/unit/indirector/file_metadata/local.rb deleted file mode 100755 index 289aee449..000000000 --- a/spec/unit/indirector/file_metadata/local.rb +++ /dev/null @@ -1,82 +0,0 @@ -#!/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/local' - -describe Puppet::Indirector::FileMetadata::Local do - it "should be registered with the file_metadata indirection" do - Puppet::Indirector::Terminus.terminus_class(:file_metadata, :local).should equal(Puppet::Indirector::FileMetadata::Local) - end -end - -describe Puppet::Indirector::FileMetadata::Local, "when finding a single file" do - before do - @metadata = Puppet::Indirector::FileMetadata::Local.new - @uri = "file:///my/local" - - @data = mock 'metadata' - end - - it "should return a Metadata instance created with the full path to the file if the file exists" do - @data.stubs(:collect_attributes) - - FileTest.expects(:exists?).with("/my/local").returns true - Puppet::FileServing::Metadata.expects(:new).with("/my/local", :links => nil).returns(@data) - @metadata.find(@uri).should == @data - end - - it "should pass the :links setting on to the created Content instance if the file exists" do - @data.stubs(:collect_attributes) - - FileTest.expects(:exists?).with("/my/local").returns true - Puppet::FileServing::Metadata.expects(:new).with("/my/local", :links => :manage).returns(@data) - @metadata.find(@uri, :links => :manage) - end - - it "should collect its attributes when a file is found" do - @data.expects(:collect_attributes) - - FileTest.expects(:exists?).with("/my/local").returns true - Puppet::FileServing::Metadata.expects(:new).with("/my/local", :links => nil).returns(@data) - @metadata.find(@uri).should == @data - end - - it "should return nil if the file does not exist" do - FileTest.expects(:exists?).with("/my/local").returns false - @metadata.find(@uri).should be_nil - end -end - -describe Puppet::Indirector::FileMetadata::Local, "when searching for multiple files" do - before do - @metadata = Puppet::Indirector::FileMetadata::Local.new - @uri = "file:///my/local" - end - - it "should return nil if the file does not exist" do - FileTest.expects(:exists?).with("/my/local").returns false - @metadata.find(@uri).should be_nil - end - - it "should use :path2instances from the terminus_helper to return instances if the file exists" do - FileTest.expects(:exists?).with("/my/local").returns true - @metadata.expects(:path2instances).with("/my/local", {}).returns([]) - @metadata.search(@uri) - end - - it "should pass any options on to :path2instances" do - FileTest.expects(:exists?).with("/my/local").returns true - @metadata.expects(:path2instances).with("/my/local", :testing => :one, :other => :two).returns([]) - @metadata.search(@uri, :testing => :one, :other => :two) - end - - it "should collect the attributes of the instances returned" do - FileTest.expects(:exists?).with("/my/local").returns true - @metadata.expects(:path2instances).with("/my/local", {}).returns( [mock("one", :collect_attributes => nil), mock("two", :collect_attributes => nil)] ) - @metadata.search(@uri) - end -end -- cgit