Skip to content
This repository has been archived by the owner on Dec 31, 2022. It is now read-only.

Commit

Permalink
feat(db): added postgis driver
Browse files Browse the repository at this point in the history
Resolves #165
  • Loading branch information
ajgon committed Jun 22, 2018
1 parent bb04fb4 commit a6462d7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
12 changes: 12 additions & 0 deletions libraries/drivers_db_postgis.rb
@@ -0,0 +1,12 @@
# frozen_string_literal: true

module Drivers
module Db
class Postgis < Base
adapter :postgis
allowed_engines :postgis
packages debian: 'libpq-dev', rhel: 'postgresql96-devel'
end
end
end

22 changes: 21 additions & 1 deletion spec/unit/recipes/configure_spec.rb
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 a6462d7

Please sign in to comment.