Skip to content

Commit

Permalink
feat(db): added postgis driver
Browse files Browse the repository at this point in the history
Resolves ajgon#165
  • Loading branch information
ajgon authored and kpheasey committed Apr 11, 2019
1 parent f81e109 commit 80f42dc
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/source/attributes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ database
- ``app['database']['adapter']``

- **Supported values:** ``mariadb``, ``mysql``, ``postgresql``, ``sqlite3``, ``null``
- **Supported values:** ``mariadb``, ``mysql``, ``postgis``, ``postgresql``, ``sqlite3``, ``null``
- **Default:** ``sqlite3``
- ActiveRecord adapter which will be used for database connection. ``null`` means
that no database will be configured, and is currently only tested with the ``rails``
Expand Down
11 changes: 11 additions & 0 deletions libraries/drivers_db_postgis.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

module Drivers
module Db
class Postgis < Base
adapter :postgis
allowed_engines :postgis
packages debian: %w[libpq-dev libgeos-dev], rhel: %w[postgresql96-devel libgeos-devel]
end
end
end
22 changes: 21 additions & 1 deletion spec/unit/recipes/configure_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -827,10 +827,17 @@
end
end

context 'Postgres + Passenger + Apache2' do
context 'Postgres (postgis) + Passenger + Apache2' do
let(:chef_runner) do
ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '14.04') do |solo_node|
deploy = node['deploy']
deploy['dummy_project']['database'] = {
'adapter' => 'postgis',
'username' => 'dbuser',
'password' => '03c1bc98cdd5eb2f9c75',
'host' => 'dummy-project.c298jfowejf.us-west-2.rds.amazon.com',
'port' => 3265
}
deploy['dummy_project']['appserver']['adapter'] = 'passenger'
deploy['dummy_project']['appserver']['max_pool_size'] = 10
deploy['dummy_project']['appserver']['min_instances'] = 5
Expand All @@ -842,6 +849,19 @@
end
let(:chef_run) { chef_runner.converge(described_recipe) }

before do
stub_search(:aws_opsworks_rds_db_instance, '*:*').and_return([])
end

it 'creates proper database.yml template' do
db_config = Drivers::Db::Postgis.new(chef_run, aws_opsworks_app).out
expect(db_config[:adapter]).to eq 'postgis'
expect(chef_run)
.to render_file("/srv/www/#{aws_opsworks_app['shortname']}/shared/config/database.yml").with_content(
JSON.parse({ development: db_config, production: db_config }.to_json).to_yaml
)
end

it 'creates apache2 passenger config' do
expect(chef_run)
.to render_file("/etc/apache2/sites-available/#{aws_opsworks_app['shortname']}.conf")
Expand Down

0 comments on commit 80f42dc

Please sign in to comment.