diff options
| author | Pieter van de Bruggen <pieter@puppetlabs.com> | 2011-03-23 13:59:44 -0700 |
|---|---|---|
| committer | Pieter van de Bruggen <pieter@puppetlabs.com> | 2011-03-23 13:59:44 -0700 |
| commit | 1187a0eb2550f04d9b6c3dcfdcacdfbb32de0e56 (patch) | |
| tree | bfa547837e6112bfd274f16941461b942aa19f43 /spec/unit/interface | |
| parent | f7db67513cace1efaf054406dae040dab2c44efd (diff) | |
| download | puppet-1187a0eb2550f04d9b6c3dcfdcacdfbb32de0e56.tar.gz puppet-1187a0eb2550f04d9b6c3dcfdcacdfbb32de0e56.tar.xz puppet-1187a0eb2550f04d9b6c3dcfdcacdfbb32de0e56.zip | |
(#6770) Add basic versioning for interfaces.
Reviewed-By: Nick Lewis
Diffstat (limited to 'spec/unit/interface')
| -rw-r--r-- | spec/unit/interface/action_builder_spec.rb | 2 | ||||
| -rw-r--r-- | spec/unit/interface/action_spec.rb | 4 | ||||
| -rw-r--r-- | spec/unit/interface/catalog_spec.rb | 3 | ||||
| -rw-r--r-- | spec/unit/interface/certificate_request_spec.rb | 3 | ||||
| -rw-r--r-- | spec/unit/interface/certificate_revocation_list_spec.rb | 3 | ||||
| -rw-r--r-- | spec/unit/interface/certificate_spec.rb | 3 | ||||
| -rw-r--r-- | spec/unit/interface/config_spec.rb | 3 | ||||
| -rw-r--r-- | spec/unit/interface/configurer_spec.rb | 5 | ||||
| -rw-r--r-- | spec/unit/interface/facts_spec.rb | 3 | ||||
| -rw-r--r-- | spec/unit/interface/file_spec.rb | 3 | ||||
| -rw-r--r-- | spec/unit/interface/indirector_spec.rb | 4 | ||||
| -rw-r--r-- | spec/unit/interface/interface_collection_spec.rb | 40 | ||||
| -rw-r--r-- | spec/unit/interface/key_spec.rb | 3 | ||||
| -rw-r--r-- | spec/unit/interface/node_spec.rb | 3 | ||||
| -rw-r--r-- | spec/unit/interface/report_spec.rb | 3 | ||||
| -rw-r--r-- | spec/unit/interface/resource_spec.rb | 3 | ||||
| -rw-r--r-- | spec/unit/interface/resource_type_spec.rb | 3 |
17 files changed, 41 insertions, 50 deletions
diff --git a/spec/unit/interface/action_builder_spec.rb b/spec/unit/interface/action_builder_spec.rb index 39b2386dc..ba6618fa4 100644 --- a/spec/unit/interface/action_builder_spec.rb +++ b/spec/unit/interface/action_builder_spec.rb @@ -13,7 +13,7 @@ describe Puppet::Interface::ActionBuilder do end it "should define a method on the interface which invokes the action" do - interface = Puppet::Interface.new(:action_builder_test_interface) + interface = Puppet::Interface.new(:action_builder_test_interface, :version => 1) action = Puppet::Interface::ActionBuilder.build(interface, :foo) do invoke do "invoked the method" diff --git a/spec/unit/interface/action_spec.rb b/spec/unit/interface/action_spec.rb index e74fa9fcc..5be6665fb 100644 --- a/spec/unit/interface/action_spec.rb +++ b/spec/unit/interface/action_spec.rb @@ -24,7 +24,7 @@ describe Puppet::Interface::Action do describe "when invoking" do it "should be able to call other actions on the same object" do - interface = Puppet::Interface.new(:my_interface) do + interface = Puppet::Interface.new(:my_interface, :version => 1) do action(:foo) do invoke { 25 } end @@ -56,7 +56,7 @@ describe Puppet::Interface::Action do end end - interface = Puppet::Interface::MyInterfaceBaseClass.new(:my_inherited_interface) do + interface = Puppet::Interface::MyInterfaceBaseClass.new(:my_inherited_interface, :version => 1) do action(:baz) do invoke { "the value of foo in baz is '#{foo}'" } end diff --git a/spec/unit/interface/catalog_spec.rb b/spec/unit/interface/catalog_spec.rb index 78d62110f..a59f9c952 100644 --- a/spec/unit/interface/catalog_spec.rb +++ b/spec/unit/interface/catalog_spec.rb @@ -1,7 +1,6 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') -require 'puppet/interface/catalog' -describe Puppet::Interface::Indirector.interface(:catalog) do +describe Puppet::Interface.interface(:catalog, 1) do end diff --git a/spec/unit/interface/certificate_request_spec.rb b/spec/unit/interface/certificate_request_spec.rb index a6ab8d17e..e818c301b 100644 --- a/spec/unit/interface/certificate_request_spec.rb +++ b/spec/unit/interface/certificate_request_spec.rb @@ -1,7 +1,6 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') -require 'puppet/interface/certificate_request' -describe Puppet::Interface::Indirector.interface(:certificate_request) do +describe Puppet::Interface.interface(:certificate_request, 1) do end diff --git a/spec/unit/interface/certificate_revocation_list_spec.rb b/spec/unit/interface/certificate_revocation_list_spec.rb index a98b48d90..0979eda1f 100644 --- a/spec/unit/interface/certificate_revocation_list_spec.rb +++ b/spec/unit/interface/certificate_revocation_list_spec.rb @@ -1,7 +1,6 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') -require 'puppet/interface/certificate_revocation_list' -describe Puppet::Interface::Indirector.interface(:certificate_revocation_list) do +describe Puppet::Interface.interface(:certificate_revocation_list, 1) do end diff --git a/spec/unit/interface/certificate_spec.rb b/spec/unit/interface/certificate_spec.rb index 6a325343f..51b79e6b0 100644 --- a/spec/unit/interface/certificate_spec.rb +++ b/spec/unit/interface/certificate_spec.rb @@ -1,7 +1,6 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') -require 'puppet/interface/certificate' -describe Puppet::Interface::Indirector.interface(:certificate) do +describe Puppet::Interface.interface(:certificate, 1) do end diff --git a/spec/unit/interface/config_spec.rb b/spec/unit/interface/config_spec.rb index e8aafd4a3..e1238b925 100644 --- a/spec/unit/interface/config_spec.rb +++ b/spec/unit/interface/config_spec.rb @@ -1,9 +1,8 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') -require 'puppet/interface/config' -describe Puppet::Interface.interface(:config) do +describe Puppet::Interface.interface(:config, 1) do it "should use Settings#print_config_options when asked to print" do Puppet.settings.stubs(:puts) Puppet.settings.expects(:print_config_options) diff --git a/spec/unit/interface/configurer_spec.rb b/spec/unit/interface/configurer_spec.rb index 4b3532c1b..b592a85bb 100644 --- a/spec/unit/interface/configurer_spec.rb +++ b/spec/unit/interface/configurer_spec.rb @@ -1,11 +1,10 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') -require 'puppet/interface/configurer' require 'puppet/indirector/catalog/rest' require 'tempfile' -describe Puppet::Interface.interface(:configurer) do +describe Puppet::Interface.interface(:configurer, 1) do describe "#synchronize" do it "should retrieve and apply a catalog and return a report" do dirname = Dir.mktmpdir("puppetdir") @@ -16,7 +15,7 @@ describe Puppet::Interface.interface(:configurer) do @catalog.add_resource(@file) Puppet::Resource::Catalog::Rest.any_instance.stubs(:find).returns(@catalog) - report = Puppet::Interface.interface(:configurer).synchronize("foo") + report = subject.synchronize("foo") report.kind.should == "apply" report.status.should == "changed" diff --git a/spec/unit/interface/facts_spec.rb b/spec/unit/interface/facts_spec.rb index d0f87d3a0..2b5731de5 100644 --- a/spec/unit/interface/facts_spec.rb +++ b/spec/unit/interface/facts_spec.rb @@ -1,9 +1,8 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') -require 'puppet/interface/facts' -describe Puppet::Interface::Indirector.interface(:facts) do +describe Puppet::Interface.interface(:facts, 1) do it "should define an 'upload' fact" do subject.should be_action(:upload) end diff --git a/spec/unit/interface/file_spec.rb b/spec/unit/interface/file_spec.rb index 54427a267..754b22875 100644 --- a/spec/unit/interface/file_spec.rb +++ b/spec/unit/interface/file_spec.rb @@ -1,7 +1,6 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') -require 'puppet/interface/file' -describe Puppet::Interface::Indirector.interface(:file) do +describe Puppet::Interface.interface(:file, 1) do end diff --git a/spec/unit/interface/indirector_spec.rb b/spec/unit/interface/indirector_spec.rb index 0eb7a9a4f..abbff150b 100644 --- a/spec/unit/interface/indirector_spec.rb +++ b/spec/unit/interface/indirector_spec.rb @@ -5,7 +5,7 @@ require 'puppet/interface/indirector' describe Puppet::Interface::Indirector do before do - @instance = Puppet::Interface::Indirector.new(:test) + @instance = Puppet::Interface::Indirector.new(:test, :version => 1) @indirection = stub 'indirection', :name => :stub_indirection @@ -24,7 +24,7 @@ describe Puppet::Interface::Indirector do it "should be able to determine its indirection" do # Loading actions here an get, um, complicated Puppet::Interface.stubs(:load_actions) - Puppet::Interface::Indirector.new(:catalog).indirection.should equal(Puppet::Resource::Catalog.indirection) + Puppet::Interface::Indirector.new(:catalog, :version => 1).indirection.should equal(Puppet::Resource::Catalog.indirection) end end diff --git a/spec/unit/interface/interface_collection_spec.rb b/spec/unit/interface/interface_collection_spec.rb index 536e694fd..ae684ca75 100644 --- a/spec/unit/interface/interface_collection_spec.rb +++ b/spec/unit/interface/interface_collection_spec.rb @@ -1,14 +1,18 @@ -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') +#!/usr/bin/env ruby -require 'puppet/interface/interface_collection' +require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') describe Puppet::Interface::InterfaceCollection do + before :all do + @interfaces = subject.instance_variable_get("@interfaces").dup + end + before :each do - subject.instance_variable_set("@interfaces", {}) + subject.instance_variable_get("@interfaces").clear end after :all do - subject.instance_variable_set("@interfaces", {}) + subject.instance_variable_set("@interfaces", @interfaces) end describe "::interfaces" do @@ -16,56 +20,56 @@ describe Puppet::Interface::InterfaceCollection do describe "::[]" do before :each do - subject.instance_variable_set("@interfaces", {:foo => 10}) + subject.instance_variable_get("@interfaces")[:foo][1] = 10 end it "should return the interface with the given name" do - subject["foo"].should == 10 + subject["foo", 1].should == 10 end it "should attempt to load the interface if it isn't found" do - subject.expects(:require).with('puppet/interface/bar') - subject["bar"] + subject.expects(:require).with('puppet/interface/v1/bar') + subject["bar", 1] end end describe "::interface?" do before :each do - subject.instance_variable_set("@interfaces", {:foo => 10}) + subject.instance_variable_get("@interfaces")[:foo][1] = 10 end it "should return true if the interface specified is registered" do - subject.interface?("foo").should == true + subject.interface?("foo", 1).should == true end it "should attempt to require the interface if it is not registered" do - subject.expects(:require).with('puppet/interface/bar') - subject.interface?("bar") + subject.expects(:require).with('puppet/interface/v1/bar') + subject.interface?("bar", 1) end it "should return true if requiring the interface registered it" do subject.stubs(:require).with do - subject.instance_variable_set("@interfaces", {:bar => 20}) + subject.instance_variable_get("@interfaces")[:bar][1] = 20 end - subject.interface?("bar").should == true + subject.interface?("bar", 1).should == true end it "should return false if the interface is not registered" do subject.stubs(:require).returns(true) - subject.interface?("bar").should == false + subject.interface?("bar", 1).should == false end it "should return false if there is a LoadError requiring the interface" do subject.stubs(:require).raises(LoadError) - subject.interface?("bar").should == false + subject.interface?("bar", 1).should == false end end describe "::register" do it "should store the interface by name" do - interface = Puppet::Interface.new(:my_interface) + interface = Puppet::Interface.new(:my_interface, :version => 1) subject.register(interface) - subject.instance_variable_get("@interfaces").should == {:my_interface => interface} + subject.instance_variable_get("@interfaces").should == {:my_interface => {1 => interface}} end end diff --git a/spec/unit/interface/key_spec.rb b/spec/unit/interface/key_spec.rb index 4b331d169..395fbef4d 100644 --- a/spec/unit/interface/key_spec.rb +++ b/spec/unit/interface/key_spec.rb @@ -1,7 +1,6 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') -require 'puppet/interface/key' -describe Puppet::Interface::Indirector.interface(:key) do +describe Puppet::Interface.interface(:key, 1) do end diff --git a/spec/unit/interface/node_spec.rb b/spec/unit/interface/node_spec.rb index b1b4ad421..bd4bc9fea 100644 --- a/spec/unit/interface/node_spec.rb +++ b/spec/unit/interface/node_spec.rb @@ -1,9 +1,8 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') -require 'puppet/interface/node' -describe Puppet::Interface::Indirector.interface(:node) do +describe Puppet::Interface.interface(:node, 1) do it "should set its default format to :yaml" do subject.default_format.should == :yaml end diff --git a/spec/unit/interface/report_spec.rb b/spec/unit/interface/report_spec.rb index c424880a9..0dd3cacf1 100644 --- a/spec/unit/interface/report_spec.rb +++ b/spec/unit/interface/report_spec.rb @@ -1,7 +1,6 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') -require 'puppet/interface/report' -describe Puppet::Interface::Indirector.interface(:report) do +describe Puppet::Interface.interface(:report, 1) do end diff --git a/spec/unit/interface/resource_spec.rb b/spec/unit/interface/resource_spec.rb index aab2753b1..5101ddbd6 100644 --- a/spec/unit/interface/resource_spec.rb +++ b/spec/unit/interface/resource_spec.rb @@ -1,7 +1,6 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') -require 'puppet/interface/resource' -describe Puppet::Interface::Indirector.interface(:resource) do +describe Puppet::Interface.interface(:resource, 1) do end diff --git a/spec/unit/interface/resource_type_spec.rb b/spec/unit/interface/resource_type_spec.rb index 6e973c98b..84afa30d4 100644 --- a/spec/unit/interface/resource_type_spec.rb +++ b/spec/unit/interface/resource_type_spec.rb @@ -1,7 +1,6 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') -require 'puppet/interface/resource_type' -describe Puppet::Interface::Indirector.interface(:resource_type) do +describe Puppet::Interface.interface(:resource_type, 1) do end |
