diff options
Diffstat (limited to 'chef/spec/unit/environment_spec.rb')
-rw-r--r-- | chef/spec/unit/environment_spec.rb | 130 |
1 files changed, 0 insertions, 130 deletions
diff --git a/chef/spec/unit/environment_spec.rb b/chef/spec/unit/environment_spec.rb index 7b0a835e8c..97f0c3395e 100644 --- a/chef/spec/unit/environment_spec.rb +++ b/chef/spec/unit/environment_spec.rb @@ -235,107 +235,6 @@ describe Chef::Environment do end end - describe "when listing the available cookbooks filtered by policy" do - before(:each) do - @environment.name "prod" - @environment.cookbook_versions({ - "apt" => "= 1.0.0", - "apache2" => "= 2.0.0" - }) - Chef::Environment.stub!(:cdb_load).and_return @environment - - @all_cookbooks = [] - @all_cookbooks << begin - cv = Chef::CookbookVersion.new("apt") - cv.version = "1.0.0" - cv.recipe_filenames = ["default.rb", "only-in-1-0.rb"] - cv - end - @all_cookbooks << begin - cv = Chef::CookbookVersion.new("apt") - cv.version = "1.1.0" - cv.recipe_filenames = ["default.rb", "only-in-1-1.rb"] - cv - end - @all_cookbooks << begin - cv = Chef::CookbookVersion.new("apache2") - cv.version = "2.0.0" - cv.recipe_filenames = ["default.rb", "mod_ssl.rb"] - cv - end - @all_cookbooks << begin - cv = Chef::CookbookVersion.new("god") - cv.version = "4.2.0" - cv.recipe_filenames = ["default.rb"] - cv - end - Chef::CookbookVersion.stub!(:cdb_list).and_return @all_cookbooks - end - - it "should load the environment" do - Chef::Environment.should_receive(:cdb_load).with("prod", nil) - Chef::Environment.cdb_load_filtered_cookbook_versions("prod") - end - - it "should handle cookbooks with no available version" do - @environment.cookbook_versions({ - "apt" => "> 999.0.0", - "apache2" => "= 2.0.0" - }) - Chef::Environment.should_receive(:cdb_load).with("prod", nil) - recipes = Chef::Environment.cdb_load_filtered_recipe_list("prod") - # order doesn't matter - recipes.should =~ ["god", "apache2", "apache2::mod_ssl"] - end - - - it "should load all the cookbook versions" do - Chef::CookbookVersion.should_receive(:cdb_list) - Chef::Environment.cdb_load_filtered_cookbook_versions("prod") - recipes = Chef::Environment.cdb_load_filtered_recipe_list("prod") - recipes.should =~ ["apache2", "apache2::mod_ssl", "apt", - "apt::only-in-1-0", "god"] - end - - it "should load all the cookbook versions with no policy" do - @environment.cookbook_versions({}) - Chef::CookbookVersion.should_receive(:cdb_list) - Chef::Environment.cdb_load_filtered_cookbook_versions("prod") - recipes = Chef::Environment.cdb_load_filtered_recipe_list("prod") - recipes.should =~ ["apache2", "apache2::mod_ssl", "apt", - "apt::only-in-1-1", "god"] - end - - it "should restrict the cookbook versions, as specified in the environment" do - res = Chef::Environment.cdb_load_filtered_cookbook_versions("prod") - res["apt"].detect {|cb| cb.version == "1.0.0"}.should_not == nil - res["apache2"].detect {|cb| cb.version == "2.0.0"}.should_not == nil - res["god"].detect {|cb| cb.version == "4.2.0"}.should_not == nil - end - - it "should produce correct results, regardless of the cookbook order in couch" do - # a bug present before the environments feature defaulted to the last CookbookVersion - # object for a cookbook as returned from couchdb when fetching cookbooks for a node - # this is a regression test - @all_cookbooks << begin - cv = Chef::CookbookVersion.new("god") - cv.version = "0.0.1" - cv - end - res = Chef::Environment.cdb_load_filtered_cookbook_versions("prod") - res["apt"].detect {|cb| cb.version == "1.0.0"}.should_not == nil - res["apache2"].detect {|cb| cb.version == "2.0.0"}.should_not == nil - res["god"].detect {|cb| cb.version == "4.2.0"}.should_not == nil - end - - it "should return all versions of a cookbook that meet the version requirement" do - @environment.cookbook "apt", ">= 1.0.0" - res = Chef::Environment.cdb_load_filtered_cookbook_versions("prod") - res["apt"].detect {|cb| cb.version == "1.0.0"}.should_not == nil - res["apt"].detect {|cb| cb.version == "1.1.0"}.should_not == nil - end - end - describe "self.validate_cookbook_versions" do before(:each) do @cookbook_versions = { @@ -376,35 +275,6 @@ describe Chef::Environment do end end - describe "self.create_default_environment" do - it "should check if the '_default' environment exists" do - @couchdb = Chef::CouchDB.new - Chef::CouchDB.stub!(:new).and_return @couchdb - Chef::Environment.should_receive(:cdb_load).with('_default', Chef::CouchDB.new) - Chef::Environment.create_default_environment - end - - it "should not re-create the environment if it exists" do - @couchdb = Chef::CouchDB.new - Chef::CouchDB.stub!(:new).and_return @couchdb - Chef::Environment.should_receive(:cdb_load).with('_default', Chef::CouchDB.new).and_return true - Chef::Environment.should_not_receive(:new) - Chef::Environment.create_default_environment - end - - it "should create the environment if it doesn't exist" do - @env = Chef::Environment.new - @env.stub!(:cdb_save).and_return true - @couchdb = Chef::CouchDB.new - Chef::Environment.stub!(:new).and_return @env - Chef::CouchDB.stub!(:new).and_return @couchdb - - Chef::Environment.should_receive(:cdb_load).with('_default', Chef::CouchDB.new).and_raise(Chef::Exceptions::CouchDBNotFound) - Chef::Environment.should_receive(:new) - Chef::Environment.create_default_environment - end - end - describe "when updating from a parameter hash" do before do @environment = Chef::Environment.new |