From 3051174dfe3a268048a9a09f159538d4491f1361 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 12 Jan 2011 17:00:01 -0800 Subject: [PATCH] Chef server config validation testing --- test/vagrant/provisioners/chef_server_test.rb | 28 ++++++++++++ test/vagrant/provisioners/chef_test.rb | 43 ------------------- 2 files changed, 28 insertions(+), 43 deletions(-) diff --git a/test/vagrant/provisioners/chef_server_test.rb b/test/vagrant/provisioners/chef_server_test.rb index 41d855fa1..a72acf7c6 100644 --- a/test/vagrant/provisioners/chef_server_test.rb +++ b/test/vagrant/provisioners/chef_server_test.rb @@ -12,6 +12,34 @@ class ChefServerProvisionerTest < Test::Unit::TestCase @vm = @action.vm end + context "config validation" do + setup do + @errors = Vagrant::Config::ErrorRecorder.new + + @config.run_list = ["foo"] + @config.chef_server_url = "foo" + @config.validation_key_path = "foo" + end + + should "be invalid if run list is empty" do + @config.run_list = [] + @config.validate(@errors) + assert !@errors.errors.empty? + end + + should "be invalid if run list is empty" do + @config.chef_server_url = nil + @config.validate(@errors) + assert !@errors.errors.empty? + end + + should "be invalid if run list is empty" do + @config.validation_key_path = nil + @config.validate(@errors) + assert !@errors.errors.empty? + end + end + context "provisioning" do should "run the proper sequence of methods in order" do prov_seq = sequence("prov_seq") diff --git a/test/vagrant/provisioners/chef_test.rb b/test/vagrant/provisioners/chef_test.rb index 3ead19c81..4946de9dc 100644 --- a/test/vagrant/provisioners/chef_test.rb +++ b/test/vagrant/provisioners/chef_test.rb @@ -63,49 +63,6 @@ class ChefProvisionerTest < Test::Unit::TestCase @config.add_role("role[user]") assert_equal "role[user]", @config.run_list[0] end - -=begin - context "validation" do - setup do - @errors = Vagrant::Config::ErrorRecorder.new - @top = @config.top = Vagrant::Config::Top.new(@env) - end - - context "chef server" do - setup do - @top.vm.provisioner = :chef_server - - @config.run_list = ["foo"] - @config.chef_server_url = "foo" - @config.validation_key_path = "foo" - end - - should "be valid if provisioner is not chef solo" do - @top.vm.provisioner = nil - @config.validate(@errors) - assert @errors.errors.empty? - end - - should "be invalid if run list is empty" do - @config.run_list = [] - @config.validate(@errors) - assert !@errors.errors.empty? - end - - should "be invalid if run list is empty" do - @config.chef_server_url = nil - @config.validate(@errors) - assert !@errors.errors.empty? - end - - should "be invalid if run list is empty" do - @config.validation_key_path = nil - @config.validate(@errors) - assert !@errors.errors.empty? - end - end - end -=end end context "verifying binary" do