forked from afair/postgresql_cursor
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added "rake setup" task to create db/table * "rake [test]" to run them
- Loading branch information
Showing
7 changed files
with
69 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,23 @@ | ||
require "bundler/gem_tasks" | ||
require "bundler/setup" | ||
require 'rake/testtask' | ||
|
||
task :default => :test | ||
|
||
desc "Run the Test Suite, toot suite" | ||
task :test do | ||
sh "ruby test/test_*" | ||
end | ||
|
||
desc "Open and IRB Console with the gem loaded" | ||
task :console do | ||
require 'irb' | ||
ARGV.clear | ||
IRB.start | ||
end | ||
|
||
desc "Setup testing database and table" | ||
task :setup do | ||
sh %q(createdb postgresql_cursor_test) | ||
sh %Q<echo "create table products ( id serial primary key);" | psql postgresql_cursor_test> | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,24 @@ | ||
$LOAD_PATH.unshift(File.dirname(__FILE__)) | ||
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) | ||
require 'rubygems' | ||
require 'minitest' | ||
require 'active_record' | ||
|
||
$LOAD_PATH.unshift(File.dirname(__FILE__)) | ||
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) | ||
require 'postgresql_cursor' | ||
|
||
ActiveRecord::Base.establish_connection :database=>'allen_test', :adapter=>'postgresql', :username=>'allen' | ||
class Model < ActiveRecord::Base | ||
#set_table_name "records" | ||
self.table_name = "records" | ||
|
||
ActiveRecord::Base.establish_connection(adapter: 'postgresql', | ||
database: ENV['TEST_DATABASE'] || 'postgresql_cursor_test', | ||
username: ENV['TEST_USER'] || ENV['USER'] || 'postgresql_cursor') | ||
class Product < ActiveRecord::Base | ||
# create table records (id serial primary key); | ||
def self.generate(max=1_000_000) | ||
max.times do | ||
connection.execute("insert into records values (nextval('records_id_seq'::regclass))") | ||
def self.generate(max=1_000) | ||
max.times do |i| | ||
connection.execute("insert into products values (#{i+1})") | ||
end | ||
end | ||
end | ||
|
||
Model.generate(1000) if Model.count == 0 | ||
|
||
class MiniTest::Unit::TestCase | ||
end | ||
Product.destroy_all | ||
Product.generate(1000) | ||
#class MiniTest::Unit::TestCase | ||
#end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters