From c61335f66f897bc64992c4e9209ea517193c8e30 Mon Sep 17 00:00:00 2001 From: Avi Miller Date: Fri, 2 Oct 2009 21:55:35 +1000 Subject: Patch to address feature #2571 to add Oracle support to Puppet Adapter requires specifying database, username and password. Signed-off-by: Avi Miller --- spec/unit/rails.rb | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 80 insertions(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/unit/rails.rb b/spec/unit/rails.rb index d98c88774..d838f0b8f 100755 --- a/spec/unit/rails.rb +++ b/spec/unit/rails.rb @@ -76,7 +76,7 @@ describe Puppet::Rails, "when initializing a sqlite3 connection" do end end -describe Puppet::Rails, "when initializing a mysql or postgresql connection" do +describe Puppet::Rails, "when initializing a mysql connection" do confine "Cannot test without ActiveRecord" => Puppet.features.rails? it "should provide the adapter, log_level, and host, username, password, and database arguments" do @@ -118,3 +118,82 @@ describe Puppet::Rails, "when initializing a mysql or postgresql connection" do } end end + +describe Puppet::Rails, "when initializing a postgresql connection" do + confine "Cannot test without ActiveRecord" => Puppet.features.rails? + + it "should provide the adapter, log_level, and host, username, password, and database arguments" do + Puppet.settings.stubs(:value).with(:dbadapter).returns("postgresql") + Puppet.settings.stubs(:value).with(:rails_loglevel).returns("testlevel") + Puppet.settings.stubs(:value).with(:dbserver).returns("testserver") + Puppet.settings.stubs(:value).with(:dbuser).returns("testuser") + Puppet.settings.stubs(:value).with(:dbpassword).returns("testpassword") + Puppet.settings.stubs(:value).with(:dbname).returns("testname") + Puppet.settings.stubs(:value).with(:dbsocket).returns("") + + Puppet::Rails.database_arguments.should == { + :adapter => "postgresql", + :log_level => "testlevel", + :host => "testserver", + :username => "testuser", + :password => "testpassword", + :database => "testname" + } + end + + it "should provide the adapter, log_level, and host, username, password, database, and socket arguments" do + Puppet.settings.stubs(:value).with(:dbadapter).returns("postgresql") + Puppet.settings.stubs(:value).with(:rails_loglevel).returns("testlevel") + Puppet.settings.stubs(:value).with(:dbserver).returns("testserver") + Puppet.settings.stubs(:value).with(:dbuser).returns("testuser") + Puppet.settings.stubs(:value).with(:dbpassword).returns("testpassword") + Puppet.settings.stubs(:value).with(:dbname).returns("testname") + Puppet.settings.stubs(:value).with(:dbsocket).returns("testsocket") + + Puppet::Rails.database_arguments.should == { + :adapter => "postgresql", + :log_level => "testlevel", + :host => "testserver", + :username => "testuser", + :password => "testpassword", + :database => "testname", + :socket => "testsocket" + } + end +end + +describe Puppet::Rails, "when initializing an Oracle connection" do + confine "Cannot test without ActiveRecord" => Puppet.features.rails? + + it "should provide the adapter, log_level, and username, password, and database arguments" do + Puppet.settings.stubs(:value).with(:dbadapter).returns("oracle_enhanced") + Puppet.settings.stubs(:value).with(:rails_loglevel).returns("testlevel") + Puppet.settings.stubs(:value).with(:dbuser).returns("testuser") + Puppet.settings.stubs(:value).with(:dbpassword).returns("testpassword") + Puppet.settings.stubs(:value).with(:dbname).returns("testname") + + Puppet::Rails.database_arguments.should == { + :adapter => "oracle_enhanced", + :log_level => "testlevel", + :username => "testuser", + :password => "testpassword", + :database => "testname" + } + end + + it "should provide the adapter, log_level, and host, username, password, database, and socket arguments" do + Puppet.settings.stubs(:value).with(:dbadapter).returns("oracle_enhanced") + Puppet.settings.stubs(:value).with(:rails_loglevel).returns("testlevel") + Puppet.settings.stubs(:value).with(:dbuser).returns("testuser") + Puppet.settings.stubs(:value).with(:dbpassword).returns("testpassword") + Puppet.settings.stubs(:value).with(:dbname).returns("testname") + + Puppet::Rails.database_arguments.should == { + :adapter => "oracle_enhanced", + :log_level => "testlevel", + :username => "testuser", + :password => "testpassword", + :database => "testname", + } + end +end -- cgit