skiima 0.1.000 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +9 -0
- data/.travis.yml +11 -3
- data/Gemfile +12 -6
- data/Guardfile +13 -11
- data/LICENSE +20 -0
- data/Procfile.example +2 -0
- data/README.md +170 -23
- data/Rakefile +26 -22
- data/lib/skiima.rb +61 -240
- data/lib/skiima/config.rb +60 -0
- data/lib/skiima/config/struct.rb +87 -0
- data/lib/skiima/db/connector.rb +195 -0
- data/lib/skiima/db/connector/active_record.rb +11 -0
- data/lib/skiima/db/connector/active_record/base_connector.rb +34 -0
- data/lib/skiima/db/connector/active_record/mysql2_connector.rb +147 -0
- data/lib/skiima/db/connector/active_record/mysql_connector.rb +177 -0
- data/lib/skiima/db/connector/active_record/postgresql_connector.rb +39 -0
- data/lib/skiima/db/helpers/mysql.rb +230 -0
- data/lib/skiima/db/helpers/postgresql.rb +221 -0
- data/lib/skiima/db/resolver.rb +62 -0
- data/lib/skiima/dependency/reader.rb +55 -0
- data/lib/skiima/dependency/script.rb +63 -0
- data/lib/skiima/i18n.rb +24 -0
- data/lib/skiima/loader.rb +108 -0
- data/lib/skiima/locales/en.yml +2 -2
- data/lib/skiima/logger.rb +54 -0
- data/lib/skiima/railtie.rb +10 -0
- data/lib/skiima/railties/skiima.rake +31 -0
- data/lib/skiima/version.rb +2 -2
- data/skiima.gemspec +5 -5
- data/spec/config/{database.yml → database.yml.example} +16 -0
- data/spec/config/database.yml.travis +69 -0
- data/spec/db/skiima/{depends.yml → dependencies.yml} +7 -2
- data/spec/db/skiima/{empty_depends.yml → empty_dependencies.yml} +0 -0
- data/spec/db/skiima/init_test_db/database.skiima_test.mysql.current.sql +7 -0
- data/spec/db/skiima/init_test_db/database.skiima_test.postgresql.current.sql +7 -0
- data/spec/mysql2_spec.rb +61 -12
- data/spec/mysql_spec.rb +66 -27
- data/spec/postgresql_spec.rb +55 -34
- data/spec/shared_examples/config_shared_example.rb +40 -0
- data/spec/skiima/config/struct_spec.rb +78 -0
- data/spec/skiima/config_spec.rb +6 -0
- data/spec/skiima/db/connector/active_record/base_connector_spec.rb +0 -0
- data/spec/skiima/db/connector/active_record/mysql2_connector_spec.rb +3 -0
- data/spec/skiima/db/connector/active_record/mysql_connector_spec.rb +3 -0
- data/spec/skiima/db/connector/active_record/postgresql_connector_spec.rb +7 -0
- data/spec/skiima/db/connector_spec.rb +6 -0
- data/spec/skiima/db/resolver_spec.rb +54 -0
- data/spec/skiima/dependency/reader_spec.rb +52 -0
- data/spec/skiima/{dependency_spec.rb → dependency/script_spec.rb} +3 -41
- data/spec/skiima/i18n_spec.rb +29 -0
- data/spec/skiima/loader_spec.rb +102 -0
- data/spec/skiima/logger_spec.rb +0 -0
- data/spec/skiima_spec.rb +43 -64
- data/spec/spec_helper.rb +38 -4
- metadata +144 -100
- data/lib/skiima/db_adapters.rb +0 -187
- data/lib/skiima/db_adapters/base_mysql_adapter.rb +0 -308
- data/lib/skiima/db_adapters/mysql2_adapter.rb +0 -114
- data/lib/skiima/db_adapters/mysql_adapter.rb +0 -287
- data/lib/skiima/db_adapters/postgresql_adapter.rb +0 -509
- data/lib/skiima/dependency.rb +0 -84
- data/lib/skiima_helpers.rb +0 -49
- data/spec/skiima/db_adapters/mysql_adapter_spec.rb +0 -38
- data/spec/skiima/db_adapters/postgresql_adapter_spec.rb +0 -20
- data/spec/skiima/db_adapters_spec.rb +0 -31
@@ -54,3 +54,19 @@ sqlserver_test:
|
|
54
54
|
username: skiima
|
55
55
|
password: test
|
56
56
|
|
57
|
+
postgresql_root:
|
58
|
+
adapter: postgresql
|
59
|
+
encoding: utf8
|
60
|
+
database: postgres
|
61
|
+
username:
|
62
|
+
password:
|
63
|
+
|
64
|
+
mysql_root:
|
65
|
+
adapter: mysql
|
66
|
+
encoding: utf8
|
67
|
+
reconnect: false
|
68
|
+
database: mysql
|
69
|
+
pool: 5
|
70
|
+
username:
|
71
|
+
password:
|
72
|
+
socket: /tmp/mysql.sock
|
@@ -0,0 +1,69 @@
|
|
1
|
+
---
|
2
|
+
production:
|
3
|
+
adapter: postgresql
|
4
|
+
encoding: utf8
|
5
|
+
database: skiima_production
|
6
|
+
username: skiima
|
7
|
+
password: test
|
8
|
+
|
9
|
+
development:
|
10
|
+
adapter: postgresql
|
11
|
+
encoding: utf8
|
12
|
+
database: skiima_development
|
13
|
+
username: skiima
|
14
|
+
password: test
|
15
|
+
|
16
|
+
test:
|
17
|
+
adapter: postgresql
|
18
|
+
encoding: utf8
|
19
|
+
database: skiima_test
|
20
|
+
username: skiima
|
21
|
+
password: test
|
22
|
+
|
23
|
+
postgresql_test:
|
24
|
+
adapter: postgresql
|
25
|
+
encoding: utf8
|
26
|
+
database: postgresql_test
|
27
|
+
username: skiima
|
28
|
+
password: test
|
29
|
+
|
30
|
+
mysql_test:
|
31
|
+
adapter: mysql
|
32
|
+
encoding: utf8
|
33
|
+
reconnect: false
|
34
|
+
database: mysql_test
|
35
|
+
pool: 5
|
36
|
+
username: skiima
|
37
|
+
password: test
|
38
|
+
|
39
|
+
mysql2_test:
|
40
|
+
adapter: mysql2
|
41
|
+
encoding: utf8
|
42
|
+
reconnect: false
|
43
|
+
database: mysql_test
|
44
|
+
pool: 5
|
45
|
+
username: skiima
|
46
|
+
password: test
|
47
|
+
|
48
|
+
sqlserver_test:
|
49
|
+
adapter: sqlserver
|
50
|
+
encoding: utf8
|
51
|
+
database: skiima_test
|
52
|
+
username: skiima
|
53
|
+
password: test
|
54
|
+
|
55
|
+
postgresql_root:
|
56
|
+
adapter: postgresql
|
57
|
+
encoding: utf8
|
58
|
+
database: postgres
|
59
|
+
username: postgres
|
60
|
+
password:
|
61
|
+
|
62
|
+
mysql_root:
|
63
|
+
adapter: mysql
|
64
|
+
encoding: utf8
|
65
|
+
reconnect: false
|
66
|
+
database: mysql
|
67
|
+
pool: 5
|
68
|
+
username: root
|
69
|
+
password:
|
@@ -48,8 +48,8 @@ test_rule:
|
|
48
48
|
test_proc:
|
49
49
|
mysql:
|
50
50
|
current:
|
51
|
-
- proc.test_proc
|
52
|
-
- proc.
|
51
|
+
- proc.test_proc
|
52
|
+
- proc.test_proc_drop
|
53
53
|
blank_group:
|
54
54
|
mysql:
|
55
55
|
postgresql:
|
@@ -59,3 +59,8 @@ only_pg:
|
|
59
59
|
current:
|
60
60
|
- table.only_pg
|
61
61
|
- view.pg_only
|
62
|
+
test_script_groups:
|
63
|
+
- test_table
|
64
|
+
- test_column_names
|
65
|
+
- test_index
|
66
|
+
- test_schema
|
File without changes
|
@@ -1,2 +1,9 @@
|
|
1
1
|
DROP DATABASE IF EXISTS &database;
|
2
|
+
--================
|
3
|
+
DROP USER '&testuser'@'localhost';
|
4
|
+
--================
|
5
|
+
CREATE USER '&testuser'@'localhost' IDENTIFIED BY '&testpass';
|
6
|
+
--================
|
2
7
|
CREATE DATABASE &database;
|
8
|
+
--================
|
9
|
+
GRANT ALL PRIVILEGES ON &database.* TO '&testuser'@'localhost';
|
@@ -1,2 +1,9 @@
|
|
1
1
|
DROP DATABASE IF EXISTS &database;
|
2
|
+
--================
|
3
|
+
DROP USER IF EXISTS &testuser;
|
4
|
+
--================
|
5
|
+
CREATE USER &testuser WITH PASSWORD '&testpass';
|
6
|
+
--================
|
2
7
|
CREATE DATABASE &database;
|
8
|
+
--================
|
9
|
+
GRANT ALL PRIVILEGES ON DATABASE &database to &testuser;
|
data/spec/mysql2_spec.rb
CHANGED
@@ -5,10 +5,10 @@ describe "Mysql2: " do
|
|
5
5
|
let(:db_config) { {} }
|
6
6
|
let(:ski) { Skiima.new(:mysql2_test) }
|
7
7
|
|
8
|
-
describe "
|
8
|
+
describe "connector Setup: " do
|
9
9
|
it "should get the version" do
|
10
10
|
ensure_closed(ski) do |s|
|
11
|
-
s.
|
11
|
+
s.connector.version.must_be_instance_of Array
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
@@ -23,17 +23,19 @@ describe "Mysql2: " do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
describe "Create/Drop Database: " do
|
26
|
-
|
26
|
+
it "skips" do
|
27
|
+
skip
|
28
|
+
end
|
27
29
|
end
|
28
30
|
|
29
31
|
describe "Create/Drop Tables: " do
|
30
32
|
it 'should be able to create and drop tables' do
|
31
33
|
ensure_closed(ski) do |s|
|
32
|
-
s.
|
34
|
+
s.connector.table_exists?('test_table').must_equal false
|
33
35
|
s.up(:test_table)
|
34
|
-
s.
|
36
|
+
s.connector.table_exists?('test_table').must_equal true
|
35
37
|
s.down(:test_table)
|
36
|
-
s.
|
38
|
+
s.connector.table_exists?('test_table').must_equal false
|
37
39
|
end
|
38
40
|
end
|
39
41
|
end
|
@@ -41,17 +43,64 @@ describe "Mysql2: " do
|
|
41
43
|
describe "Create/Drop View: " do
|
42
44
|
it 'should be able to create and drop views' do
|
43
45
|
ensure_closed(ski) do |s|
|
44
|
-
s.
|
45
|
-
s.
|
46
|
+
s.connector.table_exists?('test_table').must_equal false
|
47
|
+
s.connector.view_exists?('test_view').must_equal false
|
46
48
|
|
47
49
|
s.up(:test_table, :test_view)
|
48
|
-
s.
|
49
|
-
s.
|
50
|
+
s.connector.table_exists?('test_table').must_equal true
|
51
|
+
s.connector.view_exists?('test_view').must_equal true
|
50
52
|
|
51
53
|
s.down(:test_table, :test_view)
|
52
|
-
s.
|
53
|
-
s.
|
54
|
+
s.connector.table_exists?('test_table').must_equal false
|
55
|
+
s.connector.view_exists?('test_view').must_equal false
|
54
56
|
end
|
55
57
|
end
|
56
58
|
end
|
59
|
+
|
60
|
+
#describe "Create/Drop Index: " do
|
61
|
+
# it 'should create and drop indexes' do
|
62
|
+
# ensure_closed(ski) do |s|
|
63
|
+
# s.connector.table_exists?('test_table').must_equal false
|
64
|
+
# s.connector.index_exists?('test_index', :attr => ['test_table']).must_equal false
|
65
|
+
#
|
66
|
+
# s.up(:test_table, :test_index)
|
67
|
+
# s.connector.table_exists?('test_table').must_equal true
|
68
|
+
# s.connector.index_exists?('test_index', :attr => ['test_table']).must_equal true
|
69
|
+
#
|
70
|
+
# s.down(:test_table, :test_index)
|
71
|
+
# s.connector.table_exists?('test_table').must_equal false
|
72
|
+
# s.connector.index_exists?('test_index', :attr => ['test_table']).must_equal false
|
73
|
+
# end
|
74
|
+
# end
|
75
|
+
#end
|
76
|
+
#
|
77
|
+
#describe "Column Names: " do
|
78
|
+
# it "should get a list of column names from a table" do
|
79
|
+
# ensure_closed(ski) do |s|
|
80
|
+
# s.connector.table_exists?('test_column_names').must_equal false
|
81
|
+
# s.up(:test_column_names)
|
82
|
+
#
|
83
|
+
# s.connector.column_names('test_column_names').must_include 'id', 'first_name'
|
84
|
+
# s.down(:test_column_names)
|
85
|
+
# # { s.connector.column_names('test_column_names') }.must_raise Error
|
86
|
+
# end
|
87
|
+
# end
|
88
|
+
#end
|
89
|
+
#
|
90
|
+
#describe "Create/Drop Procs: " do
|
91
|
+
# it "should create and drop procs, with or without a drop script" do
|
92
|
+
# ensure_closed(ski) do |s|
|
93
|
+
# s.connector.proc_exists?('test_proc').must_equal false
|
94
|
+
# s.connector.proc_exists?('test_proc_drop').must_equal false
|
95
|
+
#
|
96
|
+
# s.up(:test_proc)
|
97
|
+
# s.connector.proc_exists?('test_proc').must_equal true
|
98
|
+
# s.connector.proc_exists?('test_proc_drop').must_equal true
|
99
|
+
#
|
100
|
+
# s.down(:test_proc)
|
101
|
+
# s.connector.proc_exists?('test_proc').must_equal false
|
102
|
+
# s.connector.proc_exists?('test_proc_drop').must_equal false
|
103
|
+
# end
|
104
|
+
# end
|
105
|
+
#end
|
57
106
|
end
|
data/spec/mysql_spec.rb
CHANGED
@@ -8,7 +8,7 @@ describe "Mysql: " do
|
|
8
8
|
describe "Connection Setup: " do
|
9
9
|
it "should get the version" do
|
10
10
|
ensure_closed(ski) do |s|
|
11
|
-
s.
|
11
|
+
s.connector.version.must_be_instance_of Array
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
@@ -19,17 +19,17 @@ describe "Mysql: " do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
describe "Create/Drop Database: " do
|
22
|
-
|
22
|
+
it "skips" do; skip; end
|
23
23
|
end
|
24
24
|
|
25
25
|
describe "Create/Drop Tables: " do
|
26
26
|
it 'should create and drop tables' do
|
27
27
|
ensure_closed(ski) do |s|
|
28
|
-
s.
|
28
|
+
s.connector.table_exists?('test_table').must_equal false
|
29
29
|
s.up(:test_table)
|
30
|
-
s.
|
30
|
+
s.connector.table_exists?('test_table').must_equal true
|
31
31
|
s.down(:test_table)
|
32
|
-
s.
|
32
|
+
s.connector.table_exists?('test_table').must_equal false
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
@@ -37,16 +37,16 @@ describe "Mysql: " do
|
|
37
37
|
describe "Create/Drop View: " do
|
38
38
|
it 'should create and drop views' do
|
39
39
|
ensure_closed(ski) do |s|
|
40
|
-
s.
|
41
|
-
s.
|
40
|
+
s.connector.table_exists?('test_table').must_equal false
|
41
|
+
s.connector.view_exists?('test_view').must_equal false
|
42
42
|
|
43
43
|
s.up(:test_table, :test_view)
|
44
|
-
s.
|
45
|
-
s.
|
44
|
+
s.connector.table_exists?('test_table').must_equal true
|
45
|
+
s.connector.view_exists?('test_view').must_equal true
|
46
46
|
|
47
47
|
s.down(:test_table, :test_view)
|
48
|
-
s.
|
49
|
-
s.
|
48
|
+
s.connector.table_exists?('test_table').must_equal false
|
49
|
+
s.connector.view_exists?('test_view').must_equal false
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
@@ -54,16 +54,16 @@ describe "Mysql: " do
|
|
54
54
|
describe "Create/Drop Index: " do
|
55
55
|
it 'should create and drop indexes' do
|
56
56
|
ensure_closed(ski) do |s|
|
57
|
-
s.
|
58
|
-
s.
|
57
|
+
s.connector.table_exists?('test_table').must_equal false
|
58
|
+
s.connector.index_exists?('test_index', :attr => ['test_table']).must_equal false
|
59
59
|
|
60
60
|
s.up(:test_table, :test_index)
|
61
|
-
s.
|
62
|
-
s.
|
61
|
+
s.connector.table_exists?('test_table').must_equal true
|
62
|
+
s.connector.index_exists?('test_index', :attr => ['test_table']).must_equal true
|
63
63
|
|
64
64
|
s.down(:test_table, :test_index)
|
65
|
-
s.
|
66
|
-
s.
|
65
|
+
s.connector.table_exists?('test_table').must_equal false
|
66
|
+
s.connector.index_exists?('test_index', :attr => ['test_table']).must_equal false
|
67
67
|
end
|
68
68
|
end
|
69
69
|
end
|
@@ -71,12 +71,12 @@ describe "Mysql: " do
|
|
71
71
|
describe "Column Names: " do
|
72
72
|
it "should get a list of column names from a table" do
|
73
73
|
ensure_closed(ski) do |s|
|
74
|
-
s.
|
74
|
+
s.connector.table_exists?('test_column_names').must_equal false
|
75
75
|
s.up(:test_column_names)
|
76
76
|
|
77
|
-
s.
|
77
|
+
s.connector.column_names('test_column_names').must_include 'id', 'first_name'
|
78
78
|
s.down(:test_column_names)
|
79
|
-
# { s.
|
79
|
+
# { s.connector.column_names('test_column_names') }.must_raise Error
|
80
80
|
end
|
81
81
|
end
|
82
82
|
end
|
@@ -84,17 +84,56 @@ describe "Mysql: " do
|
|
84
84
|
describe "Create/Drop Procs: " do
|
85
85
|
it "should create and drop procs, with or without a drop script" do
|
86
86
|
ensure_closed(ski) do |s|
|
87
|
-
s.
|
88
|
-
s.
|
87
|
+
s.connector.proc_exists?('test_proc').must_equal false
|
88
|
+
s.connector.proc_exists?('test_proc_drop').must_equal false
|
89
89
|
|
90
90
|
s.up(:test_proc)
|
91
|
-
s.
|
92
|
-
s.
|
91
|
+
s.connector.proc_exists?('test_proc').must_equal true
|
92
|
+
s.connector.proc_exists?('test_proc_drop').must_equal true
|
93
93
|
|
94
94
|
s.down(:test_proc)
|
95
|
-
s.
|
96
|
-
s.
|
95
|
+
s.connector.proc_exists?('test_proc').must_equal false
|
96
|
+
s.connector.proc_exists?('test_proc_drop').must_equal false
|
97
97
|
end
|
98
98
|
end
|
99
99
|
end
|
100
|
-
end
|
100
|
+
end
|
101
|
+
|
102
|
+
## encoding: utf-8
|
103
|
+
#require 'spec_helper'
|
104
|
+
#require 'skiima/db_adapters/mysql_adapter'
|
105
|
+
#
|
106
|
+
#describe "Skiima::DbAdapters::MysqlAdapter" do
|
107
|
+
# let(:db) { Skiima.read_db_yml(Skiima.full_database_path)[:mysql_test] }
|
108
|
+
# let(:mysql_params) { [db[:host], db[:username], db[:password], db[:database], db[:port], db[:socket], Mysql::CLIENT_MULTI_RESULTS] }
|
109
|
+
# let(:mysql_adapter) { Skiima::DbAdapters::MysqlAdapter.new(Mysql.init, nil, mysql_params, db) }
|
110
|
+
#
|
111
|
+
# describe "#initialize" do
|
112
|
+
# before(:each) do
|
113
|
+
# Mysql.any_instance.expects(:real_connect)
|
114
|
+
# Skiima::DbAdapters::MysqlAdapter.any_instance.expects(:version)
|
115
|
+
# Skiima::DbAdapters::MysqlAdapter.any_instance.expects(:configure_connection)
|
116
|
+
# end
|
117
|
+
#
|
118
|
+
# it 'should set connection options and config' do
|
119
|
+
# mysql_adapter.instance_variable_get(:@connection_options).must_equal mysql_params
|
120
|
+
# mysql_adapter.instance_variable_get(:@config).must_equal db
|
121
|
+
# end
|
122
|
+
#
|
123
|
+
# it 'should set ssl options if included' do
|
124
|
+
# db.merge!({:sslkey => '123'})
|
125
|
+
# Mysql.any_instance.expects(:ssl_set)
|
126
|
+
#
|
127
|
+
# mysql_adapter
|
128
|
+
# end
|
129
|
+
#
|
130
|
+
# it 'should set encoding options if included' do
|
131
|
+
# utf = 'utf-8'
|
132
|
+
# db.merge!({:encoding => utf})
|
133
|
+
# Mysql.any_instance.expects(:options).with(Mysql::SET_CHARSET_NAME, utf)
|
134
|
+
#
|
135
|
+
# mysql_adapter
|
136
|
+
# end
|
137
|
+
# end
|
138
|
+
#
|
139
|
+
#end
|
data/spec/postgresql_spec.rb
CHANGED
@@ -4,17 +4,17 @@ require 'helpers/postgresql_spec_helper'
|
|
4
4
|
|
5
5
|
describe "Postgresql: " do
|
6
6
|
let(:ski) { Skiima.new(:postgresql_test) }
|
7
|
-
|
7
|
+
|
8
8
|
describe "Connection Setup: " do
|
9
9
|
it "should get the version" do
|
10
10
|
ensure_closed(ski) do |s|
|
11
|
-
s.
|
11
|
+
s.connector.version.must_be_instance_of Fixnum
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should get the timezone" do
|
16
16
|
ensure_closed(ski) do |s|
|
17
|
-
s.
|
17
|
+
s.connector.local_tz.must_be_instance_of String
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -29,11 +29,11 @@ describe "Postgresql: " do
|
|
29
29
|
it "should create and drop a table" do
|
30
30
|
ensure_closed(ski) do |skiima|
|
31
31
|
within_transaction(skiima) do |s|
|
32
|
-
s.
|
32
|
+
s.connector.table_exists?('test_table').must_equal false
|
33
33
|
s.up(:test_table)
|
34
|
-
s.
|
34
|
+
s.connector.table_exists?('test_table').must_equal true
|
35
35
|
s.down(:test_table)
|
36
|
-
s.
|
36
|
+
s.connector.table_exists?('test_table').must_equal false
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
@@ -47,11 +47,11 @@ describe "Postgresql: " do
|
|
47
47
|
#schema's cant be rolled back
|
48
48
|
it "should create and drop schemas" do
|
49
49
|
ensure_closed(ski) do |s|
|
50
|
-
s.
|
50
|
+
s.connector.schema_exists?('test_schema').must_equal false
|
51
51
|
s.up(:test_schema)
|
52
|
-
s.
|
52
|
+
s.connector.schema_exists?('test_schema').must_equal true
|
53
53
|
s.down(:test_schema)
|
54
|
-
s.
|
54
|
+
s.connector.schema_exists?('test_schema').must_equal false
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
@@ -60,16 +60,16 @@ describe "Postgresql: " do
|
|
60
60
|
it "should create and drop views" do
|
61
61
|
ensure_closed(ski) do |skiima|
|
62
62
|
within_transaction(skiima) do |s|
|
63
|
-
s.
|
64
|
-
s.
|
63
|
+
s.connector.table_exists?('test_table').must_equal false
|
64
|
+
s.connector.view_exists?('test_view').must_equal false
|
65
65
|
|
66
66
|
s.up(:test_table, :test_view)
|
67
|
-
s.
|
68
|
-
s.
|
67
|
+
s.connector.table_exists?('test_table').must_equal true
|
68
|
+
s.connector.view_exists?('test_view').must_equal true
|
69
69
|
|
70
70
|
s.down(:test_table, :test_view)
|
71
|
-
s.
|
72
|
-
s.
|
71
|
+
s.connector.table_exists?('test_table').must_equal false
|
72
|
+
s.connector.view_exists?('test_view').must_equal false
|
73
73
|
end
|
74
74
|
end
|
75
75
|
end
|
@@ -79,19 +79,19 @@ describe "Postgresql: " do
|
|
79
79
|
it "should create and drop rules" do
|
80
80
|
ensure_closed(ski) do |skiima|
|
81
81
|
within_transaction(skiima) do |s|
|
82
|
-
s.
|
83
|
-
s.
|
84
|
-
s.
|
82
|
+
s.connector.table_exists?('test_table').must_equal false
|
83
|
+
s.connector.view_exists?('test_view').must_equal false
|
84
|
+
s.connector.rule_exists?('test_rule', :attr => ['test_view']).must_equal false
|
85
85
|
|
86
86
|
s.up(:test_table, :test_view, :test_rule)
|
87
|
-
s.
|
88
|
-
s.
|
89
|
-
s.
|
87
|
+
s.connector.table_exists?('test_table').must_equal true
|
88
|
+
s.connector.view_exists?('test_view').must_equal true
|
89
|
+
s.connector.rule_exists?('test_rule', :attr => ['test_view']).must_equal true
|
90
90
|
|
91
91
|
s.down(:test_table, :test_view, :test_rule)
|
92
|
-
s.
|
93
|
-
s.
|
94
|
-
s.
|
92
|
+
s.connector.table_exists?('test_table').must_equal false
|
93
|
+
s.connector.view_exists?('test_view').must_equal false
|
94
|
+
s.connector.rule_exists?('test_rule', :attr => ['test_view']).must_equal false
|
95
95
|
end
|
96
96
|
end
|
97
97
|
end
|
@@ -101,38 +101,59 @@ describe "Postgresql: " do
|
|
101
101
|
it "should create and drop indexes" do
|
102
102
|
ensure_closed(ski) do |skiima|
|
103
103
|
within_transaction(skiima) do |s|
|
104
|
-
s.
|
105
|
-
s.
|
104
|
+
s.connector.table_exists?('test_table').must_equal false
|
105
|
+
s.connector.index_exists?('test_index', :attr => ['test_table']).must_equal false
|
106
106
|
|
107
107
|
s.up(:test_table, :test_index)
|
108
|
-
s.
|
109
|
-
s.
|
108
|
+
s.connector.table_exists?('test_table').must_equal true
|
109
|
+
s.connector.index_exists?('test_index', :attr => ['test_table']).must_equal true
|
110
110
|
|
111
111
|
s.down(:test_table, :test_index)
|
112
|
-
s.
|
113
|
-
s.
|
112
|
+
s.connector.table_exists?('test_table').must_equal false
|
113
|
+
s.connector.index_exists?('test_index', :attr => ['test_table']).must_equal false
|
114
114
|
end
|
115
115
|
end
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
119
119
|
describe "Create/Drop Users: " do
|
120
|
-
|
120
|
+
|
121
121
|
end
|
122
122
|
|
123
123
|
describe "Column Names: " do
|
124
124
|
it "should get a list of column names from a table" do
|
125
125
|
ensure_closed(ski) do |skiima|
|
126
126
|
within_transaction(skiima) do |s|
|
127
|
-
s.
|
127
|
+
s.connector.table_exists?('test_column_names').must_equal false
|
128
128
|
s.up(:test_column_names)
|
129
129
|
|
130
|
-
s.
|
130
|
+
s.connector.column_names('test_column_names').must_include 'id', 'first_name'
|
131
131
|
s.down(:test_column_names)
|
132
132
|
# { s.connection.column_names('test_column_names') }.must_raise Error
|
133
133
|
end
|
134
|
-
end
|
134
|
+
end
|
135
135
|
end
|
136
136
|
end
|
137
137
|
end
|
138
138
|
|
139
|
+
## encoding: utf-8
|
140
|
+
#require 'spec_helper'
|
141
|
+
#require 'skiima/db_adapters/postgresql_adapter'
|
142
|
+
#
|
143
|
+
#describe "Skiima::DbAdapters::PostgresqlAdapter" do
|
144
|
+
# let(:db) { Skiima.read_db_yml(Skiima.full_database_path)[:test] }
|
145
|
+
# let(:pg_params) { [db[:host], db[:port], nil, nil, db[:database], db[:username], db[:password]] }
|
146
|
+
# let(:pg_adapter) { Skiima::DbAdapters::PostgresqlAdapter.new(nil, nil, pg_params, db) }
|
147
|
+
#
|
148
|
+
# describe "#initialize" do
|
149
|
+
# it 'should set params, attempt to connect, check the version, and get the timezone' do
|
150
|
+
# Skiima::DbAdapters::PostgresqlAdapter.any_instance.expects(:connect)
|
151
|
+
# Skiima::DbAdapters::PostgresqlAdapter.any_instance.expects(:postgresql_version).returns(80300)
|
152
|
+
# Skiima::DbAdapters::PostgresqlAdapter.any_instance.expects(:get_timezone).returns('UTC')
|
153
|
+
#
|
154
|
+
# pg_adapter.version.must_equal 80300
|
155
|
+
# pg_adapter.local_tz.must_equal 'UTC'
|
156
|
+
# end
|
157
|
+
# end
|
158
|
+
#end
|
159
|
+
|