Reworked tests to get them to pass
* brought in dependent cookbooks in librarian * updated to most recent version of chefspec
This commit is contained in:
4
Cheffile
4
Cheffile
@@ -1,3 +1,7 @@
|
|||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
site "http://community.opscode.com/api/v1"
|
site "http://community.opscode.com/api/v1"
|
||||||
|
|
||||||
|
cookbook "database"
|
||||||
|
cookbook "openstack-utils",
|
||||||
|
:git => "git@github.com:att-cloud/cookbook-openstack-utils.git"
|
||||||
|
|||||||
2
Gemfile
2
Gemfile
@@ -1,6 +1,6 @@
|
|||||||
source :rubygems
|
source :rubygems
|
||||||
|
|
||||||
gem "chefspec", :git => "git://github.com/acrmp/chefspec.git"
|
gem "chefspec", "~> 0.9.0"
|
||||||
gem "librarian", "~> 0.0.24"
|
gem "librarian", "~> 0.0.24"
|
||||||
gem "foodcritic", "~> 1.6.1"
|
gem "foodcritic", "~> 1.6.1"
|
||||||
gem "hashie", "~> 1.2.0"
|
gem "hashie", "~> 1.2.0"
|
||||||
|
|||||||
17
Gemfile.lock
17
Gemfile.lock
@@ -1,13 +1,3 @@
|
|||||||
GIT
|
|
||||||
remote: git://github.com/acrmp/chefspec.git
|
|
||||||
revision: 5cb01c464a572132edac802549efbc3c7c85485a
|
|
||||||
specs:
|
|
||||||
chefspec (0.8.0)
|
|
||||||
chef (>= 0.9.12)
|
|
||||||
erubis
|
|
||||||
minitest-chef-handler (~> 0.6.0)
|
|
||||||
rspec (~> 2.11.0)
|
|
||||||
|
|
||||||
GEM
|
GEM
|
||||||
remote: http://rubygems.org/
|
remote: http://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
@@ -32,6 +22,11 @@ GEM
|
|||||||
treetop (~> 1.4.9)
|
treetop (~> 1.4.9)
|
||||||
uuidtools
|
uuidtools
|
||||||
yajl-ruby (~> 1.1)
|
yajl-ruby (~> 1.1)
|
||||||
|
chefspec (0.9.0)
|
||||||
|
chef (>= 0.9.12)
|
||||||
|
erubis
|
||||||
|
minitest-chef-handler (~> 0.6.0)
|
||||||
|
rspec (~> 2.11.0)
|
||||||
ci_reporter (1.7.3)
|
ci_reporter (1.7.3)
|
||||||
builder (>= 2.1.2)
|
builder (>= 2.1.2)
|
||||||
coderay (1.0.8)
|
coderay (1.0.8)
|
||||||
@@ -115,7 +110,7 @@ PLATFORMS
|
|||||||
ruby
|
ruby
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
chefspec!
|
chefspec (~> 0.9.0)
|
||||||
foodcritic (~> 1.6.1)
|
foodcritic (~> 1.6.1)
|
||||||
hashie (~> 1.2.0)
|
hashie (~> 1.2.0)
|
||||||
librarian (~> 0.0.24)
|
librarian (~> 0.0.24)
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ module Openstack
|
|||||||
user_prov = Chef::Provider::Database::PostgresqlUser
|
user_prov = Chef::Provider::Database::PostgresqlUser
|
||||||
# See https://github.com/opscode-cookbooks/postgresql/blob/master/recipes/server.rb#L41
|
# See https://github.com/opscode-cookbooks/postgresql/blob/master/recipes/server.rb#L41
|
||||||
super_user = 'postgres'
|
super_user = 'postgres'
|
||||||
super_password = node['postgresql']['password']['postgres']
|
super_password = @node['postgresql']['password']['postgres']
|
||||||
when 'mysql'
|
when 'mysql'
|
||||||
db_prov = Chef::Provider::Database::Mysql
|
db_prov = Chef::Provider::Database::Mysql
|
||||||
user_prov = Chef::Provider::Database::MysqlUser
|
user_prov = Chef::Provider::Database::MysqlUser
|
||||||
@@ -110,7 +110,7 @@ module Openstack
|
|||||||
|
|
||||||
# For some reason, setting this to anything other than localhost fails miserably :(
|
# For some reason, setting this to anything other than localhost fails miserably :(
|
||||||
host = 'localhost'
|
host = 'localhost'
|
||||||
super_password = node['mysql']['server_root_password']
|
super_password = @node['mysql']['server_root_password']
|
||||||
else
|
else
|
||||||
Chef::Log.error("Unsupported database type #{type}")
|
Chef::Log.error("Unsupported database type #{type}")
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,7 +3,10 @@ require ::File.join ::File.dirname(__FILE__), "..", "libraries", "default"
|
|||||||
|
|
||||||
describe ::Openstack do
|
describe ::Openstack do
|
||||||
before do
|
before do
|
||||||
@chef_run = ::ChefSpec::ChefRunner.new.converge "openstack-common::default"
|
@chef_run = ::ChefSpec::ChefRunner.new do |n|
|
||||||
|
n.set['mysql'] = {}
|
||||||
|
n.set['mysql']['server_root_password'] = "pass"
|
||||||
|
end.converge "openstack-common::default"
|
||||||
@subject = ::Object.new.extend(::Openstack)
|
@subject = ::Object.new.extend(::Openstack)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -140,15 +143,12 @@ describe ::Openstack do
|
|||||||
@subject.db_create_with_user("nonexisting", "user", "pass").should be_nil
|
@subject.db_create_with_user("nonexisting", "user", "pass").should be_nil
|
||||||
end
|
end
|
||||||
it "returns db info and creates database with user when service found" do
|
it "returns db info and creates database with user when service found" do
|
||||||
stub_const("Chef::Provider::Database::Mysql", nil)
|
@subject.stub(:database).and_return(Hash.new)
|
||||||
Chef::Recipe.any_instance.stub(:database).and_return(Hash.new)
|
@subject.stub(:database_user).and_return(Hash.new)
|
||||||
@subject.instance_variable_set(:@node, @chef_run.node)
|
@subject.instance_variable_set(:@node, @chef_run.node)
|
||||||
expect = {
|
|
||||||
'host' => '127.0.0.1',
|
|
||||||
'port' => 3306
|
|
||||||
}
|
|
||||||
result = @subject.db_create_with_user("compute", "user", "pass")
|
result = @subject.db_create_with_user("compute", "user", "pass")
|
||||||
result.should eq expect
|
result['host'].should eq "127.0.0.1"
|
||||||
|
result['port'].should eq "3306"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user