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

Commit

Permalink
Moved DB packages installation from configure to setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Rzegocki committed Apr 10, 2016
1 parent 730857f commit e23f2d4
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 18 deletions.
2 changes: 1 addition & 1 deletion libraries/drivers/db/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def out
end
# rubocop:enable Metrics/AbcSize

def configure(context)
def setup(context)
handle_packages(context)
end

Expand Down
15 changes: 0 additions & 15 deletions recipes/configure.rb

This file was deleted.

21 changes: 21 additions & 0 deletions recipes/setup.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true
#
# Cookbook Name:: opsworks_ruby
# Recipe:: setup
#

if Chef::Config[:solo]
Chef::Log.warn('This recipe uses search. Chef Solo does not support search.')
end

applications = search(:aws_opsworks_app)
rdses = search(:aws_opsworks_rds_db_instance)

node['deploy'].each do |deploy_app_id, _deploy|
application = applications.detect { |app| app['id'] == deploy_app_id }
next unless application
rdses.each do |rds|
database = Drivers::Db::Factory.build(application, node, rds: rds)
database.setup(self)
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@

require 'spec_helper'

describe 'opsworks_ruby::configure' do
let(:chef_run) { ChefSpec::SoloRunner.new.converge(described_recipe) }
describe 'opsworks_ruby::setup' do
let(:chef_run) do
ChefSpec::SoloRunner.new do |solo_node|
solo_node.set['deploy'] = node['deploy']
end.converge(described_recipe)
end

context 'Database' do
context 'Postgresql' do
before do
stub_search(:aws_opsworks_app, '*:*').and_return([aws_opsworks_app])
stub_search(:aws_opsworks_rds_db_instance, '*:*').and_return([aws_opsworks_rds_db_instance])
stub_node { |n| n.merge(node) }
end

it 'installs required packages' do
Expand Down

0 comments on commit e23f2d4

Please sign in to comment.