Permalink
Browse files

Moving SQL Server tests to the extracted adapter. References #9884.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7930 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent faa455a commit 197c8885761e79cefb58e6d6dbe0ec24b6dadc18 @jeremy jeremy committed Oct 16, 2007
@@ -28,7 +28,7 @@ task :default => :test
desc 'Run mysql, sqlite, and postgresql tests'
task :test => %w(test_mysql test_sqlite test_sqlite3 test_postgresql)
-for adapter in %w( mysql postgresql sqlite sqlite3 firebird sqlserver sqlserver_odbc db2 oracle sybase openbase frontbase )
+for adapter in %w( mysql postgresql sqlite sqlite3 firebird db2 oracle sybase openbase frontbase )
Rake::TestTask.new("test_#{adapter}") { |t|
t.libs << "test" << "test/connections/native_#{adapter}"
adapter_short = adapter == 'db2' ? adapter : adapter[/^[a-z]+/]
@@ -9,7 +9,7 @@ def setup
end
def test_drop_and_create_main_tables
- recreate ActiveRecord::Base
+ recreate ActiveRecord::Base unless use_migrations?
assert true
end
@@ -23,11 +23,16 @@ def test_load_schema
end
def test_drop_and_create_courses_table
- recreate Course, '2'
+ recreate Course, '2' unless use_migrations?
assert true
end
private
+ def use_migrations?
+ coursesSQL = ActiveRecord::Base.connection.adapter_name.downcase + "2.sql"
+ not File.exists? "#{@base_path}/#{coursesSQL}"
+ end
+
def recreate(base, suffix = nil)
connection = base.connection
adapter_name = connection.adapter_name.downcase + suffix.to_s
@@ -1,23 +0,0 @@
-print "Using native SQLServer\n"
-require_dependency 'fixtures/course'
-require 'logger'
-
-ActiveRecord::Base.logger = Logger.new("debug.log")
-
-ActiveRecord::Base.configurations = {
- 'arunit' => {
- :adapter => 'sqlserver',
- :host => 'localhost',
- :username => 'sa',
- :database => 'activerecord_unittest'
- },
- 'arunit2' => {
- :adapter => 'sqlserver',
- :host => 'localhost',
- :username => 'sa',
- :database => 'activerecord_unittest2'
- }
-}
-
-ActiveRecord::Base.establish_connection 'arunit'
-Course.establish_connection 'arunit2'
@@ -1,25 +0,0 @@
-print "Using native SQLServer via ODBC\n"
-require_dependency 'fixtures/course'
-require 'logger'
-
-ActiveRecord::Base.logger = Logger.new("debug.log")
-
-ActiveRecord::Base.configurations = {
- 'arunit' => {
- :adapter => 'sqlserver',
- :mode => 'ODBC',
- :host => 'localhost',
- :username => 'sa',
- :dsn => 'activerecord_unittest'
- },
- 'arunit2' => {
- :adapter => 'sqlserver',
- :mode => 'ODBC',
- :host => 'localhost',
- :username => 'sa',
- :dsn => 'activerecord_unittest2'
- }
-}
-
-ActiveRecord::Base.establish_connection 'arunit'
-Course.establish_connection 'arunit2'
@@ -1,35 +0,0 @@
-DROP TABLE accounts;
-DROP TABLE funny_jokes;
-DROP TABLE companies;
-DROP TABLE topics;
-DROP TABLE developers;
-DROP TABLE projects;
-DROP TABLE developers_projects;
-DROP TABLE customers;
-DROP TABLE orders;
-DROP TABLE movies;
-DROP TABLE subscribers;
-DROP TABLE booleantests;
-DROP TABLE defaults;
-DROP TABLE auto_id_tests;
-DROP TABLE entrants;
-DROP TABLE colnametests;
-DROP TABLE mixins;
-DROP TABLE people;
-DROP TABLE readers;
-DROP TABLE binaries;
-DROP TABLE computers;
-DROP TABLE posts;
-DROP TABLE comments;
-DROP TABLE authors;
-DROP TABLE tasks;
-DROP TABLE categories;
-DROP TABLE categories_posts;
-DROP TABLE fk_test_has_fk;
-DROP TABLE fk_test_has_pk;
-DROP TABLE keyboards;
-DROP TABLE legacy_things;
-DROP TABLE numeric_data;
-DROP TABLE [order];
-DROP TABLE mixed_case_monkeys;
-DROP TABLE minimalistics;
@@ -1,247 +0,0 @@
-CREATE TABLE accounts (
- id int NOT NULL IDENTITY(1, 1) PRIMARY KEY,
- firm_id int default NULL,
- credit_limit int default NULL
-);
-
-CREATE TABLE funny_jokes (
- id int NOT NULL IDENTITY(1, 1) PRIMARY KEY,
- name varchar(50) default NULL
-);
-
-CREATE TABLE companies (
- id int NOT NULL IDENTITY(1, 1) PRIMARY KEY,
- type varchar(50) default NULL,
- ruby_type varchar(50) default NULL,
- firm_id int default NULL,
- name varchar(50) default NULL,
- client_of int default NULL,
- rating int default 1
-);
-
-CREATE TABLE topics (
- id int NOT NULL IDENTITY(1, 1) PRIMARY KEY,
- title varchar(255) default NULL,
- author_name varchar(255) default NULL,
- author_email_address varchar(255) default NULL,
- written_on datetime default NULL,
- bonus_time datetime default NULL,
- last_read datetime default NULL,
- content varchar(255) default NULL,
- approved bit default 1,
- replies_count int default 0,
- parent_id int default NULL,
- type varchar(50) default NULL
-);
-
-CREATE TABLE developers (
- id int NOT NULL IDENTITY(1, 1) PRIMARY KEY,
- name varchar(100) default NULL,
- salary int default 70000,
- created_at datetime default NULL,
- updated_at datetime default NULL
-);
-
-CREATE TABLE projects (
- id int NOT NULL IDENTITY(1, 1) PRIMARY KEY,
- name varchar(100) default NULL,
- type varchar(255) default NULL
-);
-
-CREATE TABLE developers_projects (
- developer_id int NOT NULL,
- project_id int NOT NULL,
- joined_on datetime default NULL,
- access_level int default 1
-);
-
-CREATE TABLE orders (
- id int NOT NULL IDENTITY(1, 1) PRIMARY KEY,
- name varchar(100) default NULL,
- billing_customer_id int default NULL,
- shipping_customer_id int default NULL
-);
-
-
-CREATE TABLE customers (
- id int NOT NULL IDENTITY(1, 1) PRIMARY KEY,
- name varchar(100) default NULL,
- balance int default 0,
- address_street varchar(100) default NULL,
- address_city varchar(100) default NULL,
- address_country varchar(100) default NULL,
- gps_location varchar(100) default NULL
-);
-
-CREATE TABLE movies (
- movieid int NOT NULL IDENTITY(1, 1) PRIMARY KEY,
- name varchar(100) default NULL
-);
-
-CREATE TABLE subscribers (
- nick varchar(100) NOT NULL PRIMARY KEY,
- name varchar(100) default NULL
-);
-
-CREATE TABLE booleantests (
- id int NOT NULL IDENTITY(1, 1) PRIMARY KEY,
- value bit default NULL
-);
-
-CREATE TABLE defaults (
- id int NOT NULL IDENTITY(1, 1) PRIMARY KEY,
--- these brought from the PostgreSQL defaults_test.rb but
--- tests only exist for integers and decimals, currently
--- modified_date date default CURRENT_DATE,
--- modified_date_function date default now(),
--- fixed_date date default '2004-01-01',
--- modified_time timestamp default CURRENT_TIMESTAMP,
--- modified_time_function timestamp default now(),
--- fixed_time timestamp default '2004-01-01 00:00:00.000000-00',
--- char1 char(1) default 'Y',
--- char2 character varying(50) default 'a varchar field',
--- char3 text default 'a text field',
- positive_integer integer default 1,
- negative_integer integer default -1,
- decimal_number decimal(3,2) default 2.78
-);
-
-CREATE TABLE auto_id_tests (
- auto_id int NOT NULL IDENTITY(1, 1) PRIMARY KEY,
- value int default NULL
-);
-
-CREATE TABLE entrants (
- id int NOT NULL PRIMARY KEY,
- name varchar(255) NOT NULL,
- course_id int NOT NULL
-);
-
-CREATE TABLE colnametests (
- id int NOT NULL IDENTITY(1, 1) PRIMARY KEY,
- [references] int NOT NULL
-);
-
-CREATE TABLE mixins (
- id int NOT NULL IDENTITY(1, 1) PRIMARY KEY,
- parent_id int default NULL,
- pos int default NULL,
- created_at datetime default NULL,
- updated_at datetime default NULL,
- lft int default NULL,
- rgt int default NULL,
- root_id int default NULL,
- type varchar(40) default NULL
-);
-
-CREATE TABLE people (
- id int NOT NULL IDENTITY(1, 1),
- first_name varchar(40) NULL,
- lock_version int default 0,
- PRIMARY KEY (id)
-);
-
-CREATE TABLE readers (
- id int NOT NULL IDENTITY(1, 1),
- post_id int NOT NULL,
- person_id int NOT NULL,
- primary key (id)
-);
-
-CREATE TABLE binaries (
- id int NOT NULL IDENTITY(1, 1) PRIMARY KEY,
- data image NULL
-);
-
-CREATE TABLE computers (
- id int NOT NULL IDENTITY(1, 1) PRIMARY KEY,
- developer int NOT NULL,
- extendedWarranty int NOT NULL
-);
-
-CREATE TABLE posts (
- id int NOT NULL IDENTITY(1, 1) PRIMARY KEY,
- author_id int default NULL,
- title varchar(255) default NULL,
- type varchar(255) default NULL,
- body varchar(4096) default NULL
-);
-
-CREATE TABLE comments (
- id int NOT NULL IDENTITY(1, 1) PRIMARY KEY,
- post_id int default NULL,
- type varchar(255) default NULL,
- body varchar(4096) default NULL
-);
-
-CREATE TABLE authors (
- id int NOT NULL IDENTITY(1, 1) PRIMARY KEY,
- name varchar(255) default NULL
-);
-
-CREATE TABLE tasks (
- id int NOT NULL IDENTITY(1, 1) PRIMARY KEY,
- starting datetime default NULL,
- ending datetime default NULL
-);
-
-CREATE TABLE categories (
- id int NOT NULL IDENTITY(1, 1) PRIMARY KEY,
- name varchar(255),
- type varchar(255) default NULL
-);
-
-CREATE TABLE categories_posts (
- category_id int NOT NULL,
- post_id int NOT NULL
-);
-
-CREATE TABLE fk_test_has_pk (
- id INTEGER NOT NULL PRIMARY KEY
-);
-
-CREATE TABLE fk_test_has_fk (
- id INTEGER NOT NULL PRIMARY KEY,
- fk_id INTEGER NOT NULL,
-
- FOREIGN KEY (fk_id) REFERENCES fk_test_has_pk(id)
-);
-
-CREATE TABLE keyboards (
- key_number int NOT NULL IDENTITY(1, 1) PRIMARY KEY,
- name varchar(50) default NULL
-);
-
---This table has an altered lock_version column name.
-CREATE TABLE legacy_things (
- id int NOT NULL IDENTITY(1, 1),
- tps_report_number int default NULL,
- version int default 0,
- PRIMARY KEY (id)
-);
-
-CREATE TABLE numeric_data (
- id int NOT NULL IDENTITY(1, 1),
- bank_balance decimal(10,2),
- big_bank_balance decimal(15,2),
- world_population decimal(10),
- my_house_population decimal(2),
- decimal_number_with_default decimal(3,2) DEFAULT 2.78
-);
-
-CREATE TABLE [order] (
- id int NOT NULL IDENTITY(1, 1) PRIMARY KEY,
- color varchar(255),
- fruit_size varchar(255),
- texture varchar(255),
- flavor varchar(255)
-);
-
-CREATE TABLE mixed_case_monkeys (
- [monkeyID] int NOT NULL IDENTITY(1, 1),
- [fleaCount] int default NULL
-);
-
-CREATE TABLE minimalistics (
- id int NOT NULL IDENTITY(1, 1) PRIMARY KEY
-);
@@ -1,2 +0,0 @@
-DROP TABLE courses;
-
@@ -1,5 +0,0 @@
-CREATE TABLE courses (
- id int NOT NULL PRIMARY KEY,
- name varchar(255) NOT NULL
-);
-

0 comments on commit 197c888

Please sign in to comment.