1 namespace :postgresql do
2 desc 'Build the PostgreSQL test databases'
3 task :build_databases => :load_connection do
4 sh %{ createdb "#{GEM_NAME}_unittest" }
5 sh %{ psql "#{GEM_NAME}_unittest" -f #{File.join(SCHEMA_PATH, 'postgresql.sql')} }
8 desc 'Drop the PostgreSQL test databases'
9 task :drop_databases => :load_connection do
10 sh %{ dropdb "#{GEM_NAME}_unittest" }
13 desc 'Rebuild the PostgreSQL test databases'
14 task :rebuild_databases => [:drop_databases, :build_databases]
16 task :load_connection do
17 require File.join(PROJECT_ROOT, %w[lib adapter_helper postgresql])
18 spec = AdapterHelper::Postgresql.load_connection_from_env
20 options['u'] = spec[:username] if spec[:username]
21 options['p'] = spec[:password] if spec[:password]
22 options_str = options.map { |key, value| "-#{key}#{value}" }.join(" ")
23 ENV['cpk_adapter_options_str'] = options_str