coupler 0.0.6-java → 0.0.7-java
Sign up to get free protection for your applications and to get access to all the features.
- data/.vimrc +3 -3
- data/VERSION +1 -1
- data/coupler.gemspec +4 -4
- data/db/migrate/018_stub.rb +4 -0
- data/lib/coupler.rb +59 -0
- data/lib/coupler/base.rb +1 -41
- data/lib/coupler/data_uploader.rb +1 -1
- data/lib/coupler/database.rb +9 -16
- data/lib/coupler/logger.rb +2 -2
- data/lib/coupler/models.rb +16 -31
- data/lib/coupler/models/comparison.rb +1 -0
- data/lib/coupler/models/connection.rb +1 -0
- data/lib/coupler/models/field.rb +1 -0
- data/lib/coupler/models/import.rb +1 -0
- data/lib/coupler/models/job.rb +1 -0
- data/lib/coupler/models/matcher.rb +1 -0
- data/lib/coupler/models/project.rb +3 -2
- data/lib/coupler/models/resource.rb +2 -1
- data/lib/coupler/models/result.rb +1 -0
- data/lib/coupler/models/scenario.rb +2 -1
- data/lib/coupler/models/transformation.rb +1 -0
- data/lib/coupler/models/transformer.rb +1 -0
- data/lib/coupler/runner.rb +1 -1
- data/tasks/db.rake +4 -4
- data/tasks/test.rake +11 -1
- data/test/functional/test_projects.rb +1 -1
- data/test/helper.rb +2 -2
- data/test/unit/models/test_common_model.rb +4 -4
- data/test/unit/models/test_project.rb +3 -3
- data/test/unit/models/test_scenario.rb +1 -1
- data/test/unit/test_base.rb +0 -38
- data/test/unit/test_coupler.rb +28 -0
- data/test/unit/test_data_uploader.rb +2 -2
- data/test/unit/test_database.rb +4 -4
- data/test/unit/test_runner.rb +2 -3
- metadata +4 -4
- data/db/migrate/018_fix_scenario_linkage_type.rb +0 -8
- data/test/unit/test_models.rb +0 -12
data/.vimrc
CHANGED
@@ -4,11 +4,11 @@ function! s:AlternateFile()
|
|
4
4
|
let tail = fnamemodify(fn, ':t')
|
5
5
|
|
6
6
|
if match(head, '^lib/coupler/extensions') >= 0
|
7
|
-
return substitute(head, '^lib/coupler', 'test/
|
7
|
+
return substitute(head, '^lib/coupler/extensions', 'test/functional', '').'/test_'.tail
|
8
8
|
elseif match(head, '^lib') >= 0
|
9
9
|
return substitute(head, '^lib/coupler', 'test/unit', '').'/test_'.tail
|
10
|
-
elseif match(head, '^test/
|
11
|
-
return substitute(head, '^test/
|
10
|
+
elseif match(head, '^test/functional') >= 0
|
11
|
+
return substitute(head, '^test/functional', 'lib/coupler/extensions', '').'/'.substitute(tail, '^test_', '', '')
|
12
12
|
elseif match(head, '^test') >= 0
|
13
13
|
return substitute(head, '^test/unit', 'lib/coupler', '').'/'.substitute(tail, '^test_', '', '')
|
14
14
|
endif
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.7
|
data/coupler.gemspec
CHANGED
@@ -5,12 +5,12 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{coupler}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.7"
|
9
9
|
s.platform = %q{java}
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.authors = ["Jeremy Stephens"]
|
13
|
-
s.date = %q{2011-07-
|
13
|
+
s.date = %q{2011-07-19}
|
14
14
|
s.default_executable = %q{coupler}
|
15
15
|
s.description = %q{Coupler is a (JRuby) desktop application designed to link datasets together}
|
16
16
|
s.email = %q{jeremy.f.stephens@vanderbilt.edu}
|
@@ -53,7 +53,7 @@ Gem::Specification.new do |s|
|
|
53
53
|
"db/migrate/015_add_run_number_to_results.rb",
|
54
54
|
"db/migrate/016_fix_scenario_run_count.rb",
|
55
55
|
"db/migrate/017_rename_comparison_columns.rb",
|
56
|
-
"db/migrate/
|
56
|
+
"db/migrate/018_stub.rb",
|
57
57
|
"db/migrate/019_add_columns_to_imports.rb",
|
58
58
|
"db/migrate/020_rename_import_columns.rb",
|
59
59
|
"db/migrate/021_add_fields_to_connections.rb",
|
@@ -165,12 +165,12 @@ Gem::Specification.new do |s|
|
|
165
165
|
"test/unit/models/test_transformation.rb",
|
166
166
|
"test/unit/models/test_transformer.rb",
|
167
167
|
"test/unit/test_base.rb",
|
168
|
+
"test/unit/test_coupler.rb",
|
168
169
|
"test/unit/test_data_uploader.rb",
|
169
170
|
"test/unit/test_database.rb",
|
170
171
|
"test/unit/test_helpers.rb",
|
171
172
|
"test/unit/test_import_buffer.rb",
|
172
173
|
"test/unit/test_logger.rb",
|
173
|
-
"test/unit/test_models.rb",
|
174
174
|
"test/unit/test_runner.rb",
|
175
175
|
"test/unit/test_scheduler.rb",
|
176
176
|
"uploads/.gitignore",
|
data/lib/coupler.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'pp'
|
1
2
|
require 'java'
|
2
3
|
require 'jruby/core_ext'
|
3
4
|
|
@@ -23,6 +24,64 @@ require 'mongrel'
|
|
23
24
|
#require 'jdbc/mysql' # Sequel should load this when it needs to.
|
24
25
|
#require 'jdbc/h2' # Sequel should load this when it needs to.
|
25
26
|
|
27
|
+
module Coupler
|
28
|
+
def self.environment
|
29
|
+
@environment ||= ENV['COUPLER_ENV'] || :production
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.db_path(dbname)
|
33
|
+
File.join(data_path, 'db', environment.to_s, dbname)
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.connection_string(dbname)
|
37
|
+
"jdbc:h2:#{db_path(dbname)};IGNORECASE=TRUE"
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.upload_path
|
41
|
+
@upload_path ||= File.join(data_path, 'uploads', environment.to_s)
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.log_path
|
45
|
+
@log_path ||= File.join(data_path, 'log')
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.data_path
|
49
|
+
# NOTE: Unfortunately, this code is in two places. Coupler can
|
50
|
+
# be run with or without the launcher, and the launcher needs
|
51
|
+
# to know about Coupler's data path before it runs Coupler.
|
52
|
+
if !defined? @data_path
|
53
|
+
dir =
|
54
|
+
if ENV['COUPLER_HOME']
|
55
|
+
ENV['COUPLER_HOME']
|
56
|
+
else
|
57
|
+
case Config::CONFIG['host_os']
|
58
|
+
when /mswin|windows/i
|
59
|
+
# Windows
|
60
|
+
File.join(ENV['APPDATA'], "coupler")
|
61
|
+
else
|
62
|
+
if ENV['HOME']
|
63
|
+
File.join(ENV['HOME'], ".coupler")
|
64
|
+
else
|
65
|
+
raise "Can't figure out where Coupler lives! Try setting the COUPLER_HOME environment variable"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
if !File.exist?(dir)
|
70
|
+
begin
|
71
|
+
Dir.mkdir(dir)
|
72
|
+
rescue SystemCallError
|
73
|
+
raise "Can't create Coupler directory (#{dir})! Is the parent directory accessible?"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
if !File.writable?(dir)
|
77
|
+
raise "Coupler directory (#{dir}) is not writable!"
|
78
|
+
end
|
79
|
+
@data_path = File.expand_path(dir)
|
80
|
+
end
|
81
|
+
@data_path
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
26
85
|
require File.dirname(__FILE__) + "/coupler/logger"
|
27
86
|
require File.dirname(__FILE__) + "/coupler/database"
|
28
87
|
require File.dirname(__FILE__) + "/coupler/scheduler"
|
data/lib/coupler/base.rb
CHANGED
@@ -2,7 +2,7 @@ module Coupler
|
|
2
2
|
class Base < Sinatra::Base
|
3
3
|
|
4
4
|
inst_dir = File.expand_path(File.join(File.dirname(__FILE__), "..", ".."))
|
5
|
-
set :environment,
|
5
|
+
set :environment, Coupler.environment
|
6
6
|
set :root, File.join(inst_dir, "webroot")
|
7
7
|
set :static, true
|
8
8
|
set :erb, :trim => '-'
|
@@ -12,48 +12,8 @@ module Coupler
|
|
12
12
|
set :logging, Proc.new { !test? }
|
13
13
|
set :methodoverride, true
|
14
14
|
set :bind, '127.0.0.1'
|
15
|
-
set :db_path, lambda { |dbname| File.join(data_path, 'db', environment.to_s, dbname) }
|
16
|
-
set :connection_string, lambda { |dbname| "jdbc:h2:#{db_path(dbname)};IGNORECASE=TRUE" }
|
17
|
-
set :upload_path, lambda { File.join(data_path, 'uploads', environment.to_s) }
|
18
|
-
set :log_path, lambda { File.join(data_path, 'log') }
|
19
|
-
set(:data_path, lambda {
|
20
|
-
# NOTE: Unfortunately, this code is in two places. Coupler can
|
21
|
-
# be run with or without the launcher, and the launcher needs
|
22
|
-
# to know about Coupler's data path before it runs Coupler.
|
23
|
-
dir =
|
24
|
-
if ENV['COUPLER_HOME']
|
25
|
-
ENV['COUPLER_HOME']
|
26
|
-
else
|
27
|
-
case Config::CONFIG['host_os']
|
28
|
-
when /mswin|windows/i
|
29
|
-
# Windows
|
30
|
-
File.join(ENV['APPDATA'], "coupler")
|
31
|
-
else
|
32
|
-
if ENV['HOME']
|
33
|
-
File.join(ENV['HOME'], ".coupler")
|
34
|
-
else
|
35
|
-
raise "Can't figure out where Coupler lives! Try setting the COUPLER_HOME environment variable"
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
if !File.exist?(dir)
|
40
|
-
begin
|
41
|
-
Dir.mkdir(dir)
|
42
|
-
rescue SystemCallError
|
43
|
-
raise "Can't create Coupler directory (#{dir})! Is the parent directory accessible?"
|
44
|
-
end
|
45
|
-
end
|
46
|
-
if !File.writable?(dir)
|
47
|
-
raise "Coupler directory (#{dir}) is not writable!"
|
48
|
-
end
|
49
|
-
File.expand_path(dir)
|
50
|
-
})
|
51
15
|
enable :sessions
|
52
16
|
|
53
|
-
configure do
|
54
|
-
Models.load_all
|
55
|
-
end
|
56
|
-
|
57
17
|
use Rack::Flash
|
58
18
|
register Extensions::Connections
|
59
19
|
register Extensions::Projects
|
data/lib/coupler/database.rb
CHANGED
@@ -1,31 +1,24 @@
|
|
1
1
|
module Coupler
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
def initialize
|
6
|
-
@env = ENV['COUPLER_ENV']
|
7
|
-
connection_string = Base.connection_string('coupler')
|
8
|
-
@database = Sequel.connect(connection_string, :loggers => [Coupler::Logger.instance], :max_connections => 20)
|
9
|
-
super(@database)
|
10
|
-
end
|
11
|
-
|
12
|
-
def __getobj__
|
13
|
-
@database
|
14
|
-
end
|
15
|
-
|
2
|
+
Database = Sequel.connect(Coupler.connection_string('coupler'), :loggers => [Coupler::Logger.instance], :max_connections => 20)
|
3
|
+
class << Database
|
16
4
|
def rollback!
|
17
|
-
version =
|
5
|
+
version = self[:schema_info].first[:version]
|
18
6
|
migrate!(version - 1)
|
19
7
|
end
|
20
8
|
|
21
9
|
def migrate!(to = nil, from = nil)
|
22
10
|
dir = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'db', 'migrate'))
|
23
|
-
args = [
|
11
|
+
args = [self, dir]
|
24
12
|
if to
|
25
13
|
args << to
|
26
14
|
args << from if from
|
27
15
|
end
|
28
16
|
Sequel::Migrator.apply(*args)
|
29
17
|
end
|
18
|
+
|
19
|
+
def instance
|
20
|
+
warn("DEPRECATION NOTICE: Database.instance")
|
21
|
+
self
|
22
|
+
end
|
30
23
|
end
|
31
24
|
end
|
data/lib/coupler/logger.rb
CHANGED
@@ -3,9 +3,9 @@ module Coupler
|
|
3
3
|
include Singleton
|
4
4
|
|
5
5
|
def initialize
|
6
|
-
log_path =
|
6
|
+
log_path = Coupler.log_path
|
7
7
|
Dir.mkdir(log_path) if !File.exist?(log_path)
|
8
|
-
@logger = ::Logger.new(File.join(log_path, "#{
|
8
|
+
@logger = ::Logger.new(File.join(log_path, "#{Coupler.environment}.log"))
|
9
9
|
super(@logger)
|
10
10
|
end
|
11
11
|
|
data/lib/coupler/models.rb
CHANGED
@@ -1,36 +1,21 @@
|
|
1
|
+
if !defined?(Coupler::Database)
|
2
|
+
raise "Database isn't initialized yet!"
|
3
|
+
end
|
4
|
+
|
1
5
|
module Coupler
|
2
6
|
module Models
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
def self.load_all
|
17
|
-
Database.instance
|
18
|
-
NAMES.each do |name|
|
19
|
-
require File.dirname(__FILE__) + "/models/#{name.to_s.downcase}"
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.const_missing(name)
|
24
|
-
name = name.to_sym
|
25
|
-
if NAMES.include?(name)
|
26
|
-
Database.instance
|
27
|
-
require File.dirname(__FILE__) + "/models/#{name.to_s.downcase}"
|
28
|
-
const_get(name)
|
29
|
-
else
|
30
|
-
puts "#{name.inspect} wasn't in #{NAMES.inspect}"
|
31
|
-
super
|
32
|
-
end
|
33
|
-
end
|
7
|
+
autoload :Comparison, File.dirname(__FILE__) + "/models/comparison"
|
8
|
+
autoload :Connection, File.dirname(__FILE__) + "/models/connection"
|
9
|
+
autoload :Field, File.dirname(__FILE__) + "/models/field"
|
10
|
+
autoload :Import, File.dirname(__FILE__) + "/models/import"
|
11
|
+
autoload :Job, File.dirname(__FILE__) + "/models/job"
|
12
|
+
autoload :Matcher, File.dirname(__FILE__) + "/models/matcher"
|
13
|
+
autoload :Project, File.dirname(__FILE__) + "/models/project"
|
14
|
+
autoload :Resource, File.dirname(__FILE__) + "/models/resource"
|
15
|
+
autoload :Result, File.dirname(__FILE__) + "/models/result"
|
16
|
+
autoload :Scenario, File.dirname(__FILE__) + "/models/scenario"
|
17
|
+
autoload :Transformation, File.dirname(__FILE__) + "/models/transformation"
|
18
|
+
autoload :Transformer, File.dirname(__FILE__) + "/models/transformer"
|
34
19
|
end
|
35
20
|
end
|
36
21
|
|
data/lib/coupler/models/field.rb
CHANGED
data/lib/coupler/models/job.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
pp caller
|
1
2
|
module Coupler
|
2
3
|
module Models
|
3
4
|
class Project < Sequel::Model
|
@@ -15,7 +16,7 @@ module Coupler
|
|
15
16
|
|
16
17
|
private
|
17
18
|
def local_connection_string
|
18
|
-
|
19
|
+
Coupler.connection_string("project_#{id}")
|
19
20
|
end
|
20
21
|
|
21
22
|
def before_validation
|
@@ -31,7 +32,7 @@ module Coupler
|
|
31
32
|
|
32
33
|
def after_destroy
|
33
34
|
super
|
34
|
-
FileUtils.rm(Dir[
|
35
|
+
FileUtils.rm(Dir[Coupler.db_path("project_#{id}")+".*"], :force => true)
|
35
36
|
resources_dataset.each { |r| r.delete_versions_on_destroy = self.delete_versions_on_destroy; r.destroy }
|
36
37
|
scenarios_dataset.each { |s| s.delete_versions_on_destroy = self.delete_versions_on_destroy; s.destroy }
|
37
38
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
pp caller
|
1
2
|
module Coupler
|
2
3
|
module Models
|
3
4
|
class Resource < Sequel::Model
|
@@ -166,7 +167,7 @@ module Coupler
|
|
166
167
|
end
|
167
168
|
|
168
169
|
def local_connection_string
|
169
|
-
|
170
|
+
Coupler.connection_string("project_#{project.id}")
|
170
171
|
end
|
171
172
|
|
172
173
|
def create_fields
|
@@ -1,3 +1,4 @@
|
|
1
|
+
pp caller
|
1
2
|
module Coupler
|
2
3
|
module Models
|
3
4
|
class Scenario < Sequel::Model
|
@@ -75,7 +76,7 @@ module Coupler
|
|
75
76
|
private
|
76
77
|
|
77
78
|
def local_connection_string
|
78
|
-
|
79
|
+
Coupler.connection_string("scenario_#{id}")
|
79
80
|
end
|
80
81
|
|
81
82
|
def before_validation
|
data/lib/coupler/runner.rb
CHANGED
data/tasks/db.rake
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
namespace :db do
|
2
2
|
desc "Obliterate the local database"
|
3
|
-
task :nuke do
|
3
|
+
task :nuke => :environment do
|
4
4
|
confirm("This will completely obliterate all of Coupler's databases.")
|
5
5
|
|
6
6
|
require 'fileutils'
|
7
|
-
files = Dir.glob(File.join(Coupler
|
8
|
-
FileUtils.rm_rf(files
|
7
|
+
files = Dir.glob(File.join(Coupler.data_path, "db", "**", "*.db"))
|
8
|
+
FileUtils.rm_rf(files, :verbose => true)
|
9
9
|
end
|
10
10
|
|
11
11
|
desc "Purge the database"
|
12
12
|
task :purge => :environment do
|
13
|
-
FileUtils.rm(Dir[Coupler
|
13
|
+
FileUtils.rm(Dir[Coupler.db_path('coupler')+".*"])
|
14
14
|
end
|
15
15
|
|
16
16
|
desc "Run migrations"
|
data/tasks/test.rake
CHANGED
@@ -1,7 +1,17 @@
|
|
1
1
|
require 'rake/testtask'
|
2
2
|
|
3
3
|
desc "Run all tests"
|
4
|
-
task :test
|
4
|
+
task :test do
|
5
|
+
errors = %w(test:unit test:functional test:integration).collect do |task|
|
6
|
+
begin
|
7
|
+
Rake::Task[task].invoke
|
8
|
+
nil
|
9
|
+
rescue => e
|
10
|
+
task
|
11
|
+
end
|
12
|
+
end.compact
|
13
|
+
abort "Errors running #{errors * ', '}!" if errors.any?
|
14
|
+
end
|
5
15
|
|
6
16
|
namespace :test do
|
7
17
|
Rake::TestTask.new(:unit) do |test|
|
@@ -61,7 +61,7 @@ module CouplerFunctionalTests
|
|
61
61
|
yes.click
|
62
62
|
assert_equal "/projects", page.current_path
|
63
63
|
assert_nil Project[:id => project.id]
|
64
|
-
assert_nil Database
|
64
|
+
assert_nil Database[:projects_versions][:current_id => project.id]
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|
data/test/helper.rb
CHANGED
@@ -36,7 +36,7 @@ require 'coupler'
|
|
36
36
|
|
37
37
|
Coupler::Base.set(:sessions, false) # workaround
|
38
38
|
Coupler::Base.set(:environment, :test)
|
39
|
-
Coupler::Database.
|
39
|
+
Coupler::Database.migrate!
|
40
40
|
|
41
41
|
#Capybara.register_driver :selenium_chrome do |app|
|
42
42
|
#Capybara::Driver::Selenium.new(app, :browser => :chrome)
|
@@ -53,7 +53,7 @@ module Coupler
|
|
53
53
|
|
54
54
|
def setup
|
55
55
|
#@_original_connection_count = connection_count
|
56
|
-
@_database = Coupler::Database
|
56
|
+
@_database = Coupler::Database
|
57
57
|
@_database.tables.each do |name|
|
58
58
|
next if name == :schema_info
|
59
59
|
@_database[name].delete
|
@@ -5,7 +5,7 @@ module CouplerUnitTests
|
|
5
5
|
class TestCommonModel < Coupler::Test::UnitTest
|
6
6
|
def self.startup
|
7
7
|
super
|
8
|
-
db = Coupler::Database
|
8
|
+
db = Coupler::Database
|
9
9
|
db.create_table!(:foos) do
|
10
10
|
primary_key :id
|
11
11
|
String :bar
|
@@ -26,7 +26,7 @@ module CouplerUnitTests
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def self.teardown
|
29
|
-
db = Coupler::Database
|
29
|
+
db = Coupler::Database
|
30
30
|
db.drop_table(:foos)
|
31
31
|
super
|
32
32
|
end
|
@@ -59,7 +59,7 @@ module CouplerUnitTests
|
|
59
59
|
foo = @klass.create(:bar => "bar")
|
60
60
|
assert_equal 1, foo.version
|
61
61
|
|
62
|
-
versions = Database
|
62
|
+
versions = Database[:foos_versions].filter(:current_id => foo.id)
|
63
63
|
assert_equal 1, versions.count
|
64
64
|
|
65
65
|
data = versions.first
|
@@ -74,7 +74,7 @@ module CouplerUnitTests
|
|
74
74
|
foo.update(:bar => "baz")
|
75
75
|
assert_equal 2, foo.version
|
76
76
|
|
77
|
-
versions = Database
|
77
|
+
versions = Database[:foos_versions].filter(:current_id => foo.id, :version => 2)
|
78
78
|
assert_equal 1, versions.count
|
79
79
|
|
80
80
|
data = versions.first
|
@@ -57,7 +57,7 @@ module CouplerUnitTests
|
|
57
57
|
|
58
58
|
test "local_database" do
|
59
59
|
project = Project.create(:name => "foo")
|
60
|
-
FileUtils.rm(Dir[
|
60
|
+
FileUtils.rm(Dir[Coupler.db_path("project_#{project.id}")+".*"])
|
61
61
|
|
62
62
|
project.local_database do |db|
|
63
63
|
assert_kind_of Sequel::JDBC::Database, db
|
@@ -77,7 +77,7 @@ module CouplerUnitTests
|
|
77
77
|
project = Project.create(:name => "foo")
|
78
78
|
project.local_database { |db| db.test_connection } # force creation of database
|
79
79
|
project.destroy
|
80
|
-
files = Dir[
|
80
|
+
files = Dir[Coupler.db_path("project_#{project.id}")+".*"]
|
81
81
|
assert files.empty?, files.inspect
|
82
82
|
end
|
83
83
|
|
@@ -91,7 +91,7 @@ module CouplerUnitTests
|
|
91
91
|
expects(:delete_versions_on_destroy=).with(true)
|
92
92
|
}])
|
93
93
|
project.destroy
|
94
|
-
assert_equal 0, Database
|
94
|
+
assert_equal 0, Database[:projects_versions].filter(:current_id => project.id).count
|
95
95
|
end
|
96
96
|
|
97
97
|
#def test_local_database_uses_connection_class
|
@@ -171,7 +171,7 @@ module CouplerUnitTests
|
|
171
171
|
|
172
172
|
test "local database" do
|
173
173
|
scenario = new_scenario.save!
|
174
|
-
|
174
|
+
Coupler.expects(:connection_string).with("scenario_#{scenario.id}").returns("foo")
|
175
175
|
db = mock('scenario db')
|
176
176
|
Sequel.expects(:connect).with('foo', instance_of(Hash)).returns(db)
|
177
177
|
assert_equal db, scenario.local_database
|
data/test/unit/test_base.rb
CHANGED
@@ -5,43 +5,5 @@ module CouplerUnitTests
|
|
5
5
|
def test_subclasses_sinatra_base
|
6
6
|
assert_equal Sinatra::Base, Coupler::Base.superclass
|
7
7
|
end
|
8
|
-
|
9
|
-
def test_db_path
|
10
|
-
env = Base.settings.environment
|
11
|
-
begin
|
12
|
-
Base.set :environment, :production
|
13
|
-
expected = File.join(Base.settings.data_path, 'db', 'production', 'ponies')
|
14
|
-
assert_equal expected, Base.db_path("ponies")
|
15
|
-
ensure
|
16
|
-
Base.set :environment, env
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_connection_string
|
21
|
-
env = Base.settings.environment
|
22
|
-
begin
|
23
|
-
Base.set :environment, :production
|
24
|
-
expected = "jdbc:h2:#{File.join(Base.settings.data_path, 'db', 'production', 'ponies')};IGNORECASE=TRUE"
|
25
|
-
assert_equal expected, Base.connection_string("ponies")
|
26
|
-
ensure
|
27
|
-
Base.set :environment, env
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_upload_path
|
32
|
-
env = Base.settings.environment
|
33
|
-
begin
|
34
|
-
Base.set :environment, :production
|
35
|
-
expected = File.join(Base.settings.data_path, 'uploads', 'production')
|
36
|
-
assert_equal expected, Base.upload_path
|
37
|
-
ensure
|
38
|
-
Base.set :environment, env
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_log_path
|
43
|
-
expected = File.join(Base.settings.data_path, 'log')
|
44
|
-
assert_equal expected, Base.log_path
|
45
|
-
end
|
46
8
|
end
|
47
9
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
module CouplerUnitTests
|
4
|
+
class TestCoupler < Coupler::Test::UnitTest
|
5
|
+
def test_db_path
|
6
|
+
env = Coupler.environment
|
7
|
+
expected = File.join(Coupler.data_path, 'db', env, 'ponies')
|
8
|
+
assert_equal expected, Coupler.db_path("ponies")
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_connection_string
|
12
|
+
env = Coupler.environment
|
13
|
+
expected = "jdbc:h2:#{File.join(Coupler.data_path, 'db', env, 'ponies')};IGNORECASE=TRUE"
|
14
|
+
assert_equal expected, Coupler.connection_string("ponies")
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_upload_path
|
18
|
+
env = Coupler.environment
|
19
|
+
expected = File.join(Coupler.data_path, 'uploads', env)
|
20
|
+
assert_equal expected, Coupler.upload_path
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_log_path
|
24
|
+
expected = File.join(Coupler.data_path, 'log')
|
25
|
+
assert_equal expected, Coupler.log_path
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -7,13 +7,13 @@ module CouplerUnitTests
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def test_store_dir_same_as_upload_path
|
10
|
-
|
10
|
+
Coupler.expects(:upload_path).returns("/path/to/uploads")
|
11
11
|
uploader = DataUploader.new
|
12
12
|
assert_equal "/path/to/uploads", uploader.store_dir
|
13
13
|
end
|
14
14
|
|
15
15
|
def test_cache_dir_uses_upload_path
|
16
|
-
|
16
|
+
Coupler.expects(:upload_path).returns("/path/to/uploads")
|
17
17
|
uploader = DataUploader.new
|
18
18
|
assert_equal "/path/to/uploads/tmp", uploader.cache_dir
|
19
19
|
end
|
data/test/unit/test_database.rb
CHANGED
@@ -4,19 +4,19 @@ module CouplerUnitTests
|
|
4
4
|
class TestDatabase < Coupler::Test::UnitTest
|
5
5
|
def setup
|
6
6
|
super
|
7
|
-
@database = Coupler::Database
|
7
|
+
@database = Coupler::Database
|
8
8
|
end
|
9
9
|
|
10
10
|
def test_connection
|
11
|
-
assert_kind_of Sequel::JDBC::Database, @database
|
11
|
+
assert_kind_of Sequel::JDBC::Database, @database
|
12
12
|
|
13
|
-
expected =
|
13
|
+
expected = Coupler.connection_string('coupler')
|
14
14
|
assert_equal expected, @database.uri
|
15
15
|
end
|
16
16
|
|
17
17
|
def test_migrate
|
18
18
|
dir = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "db", "migrate"))
|
19
|
-
Sequel::Migrator.expects(:apply).with(@database
|
19
|
+
Sequel::Migrator.expects(:apply).with(@database, dir)
|
20
20
|
@database.migrate!
|
21
21
|
end
|
22
22
|
end
|
data/test/unit/test_runner.rb
CHANGED
@@ -6,8 +6,7 @@ module CouplerUnitTests
|
|
6
6
|
super
|
7
7
|
@scheduler = stub("scheduler", :is_started? => true, :start => nil)
|
8
8
|
Scheduler.stubs(:instance).returns(@scheduler)
|
9
|
-
|
10
|
-
Database.stubs(:instance).returns(@database)
|
9
|
+
Database.stubs(:migrate!)
|
11
10
|
@app = stub('rack app')
|
12
11
|
@handler = stub('rack handler', :new => @app)
|
13
12
|
Rack::Handler.stubs(:get).returns(@handler)
|
@@ -51,7 +50,7 @@ module CouplerUnitTests
|
|
51
50
|
end
|
52
51
|
|
53
52
|
test "migrates the database" do
|
54
|
-
|
53
|
+
Database.expects(:migrate!)
|
55
54
|
capture_stdout { Runner.new([]) }
|
56
55
|
end
|
57
56
|
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: coupler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.7
|
6
6
|
platform: java
|
7
7
|
authors:
|
8
8
|
- Jeremy Stephens
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-07-
|
13
|
+
date: 2011-07-19 00:00:00 -05:00
|
14
14
|
default_executable: coupler
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -287,7 +287,7 @@ files:
|
|
287
287
|
- db/migrate/015_add_run_number_to_results.rb
|
288
288
|
- db/migrate/016_fix_scenario_run_count.rb
|
289
289
|
- db/migrate/017_rename_comparison_columns.rb
|
290
|
-
- db/migrate/
|
290
|
+
- db/migrate/018_stub.rb
|
291
291
|
- db/migrate/019_add_columns_to_imports.rb
|
292
292
|
- db/migrate/020_rename_import_columns.rb
|
293
293
|
- db/migrate/021_add_fields_to_connections.rb
|
@@ -399,12 +399,12 @@ files:
|
|
399
399
|
- test/unit/models/test_transformation.rb
|
400
400
|
- test/unit/models/test_transformer.rb
|
401
401
|
- test/unit/test_base.rb
|
402
|
+
- test/unit/test_coupler.rb
|
402
403
|
- test/unit/test_data_uploader.rb
|
403
404
|
- test/unit/test_database.rb
|
404
405
|
- test/unit/test_helpers.rb
|
405
406
|
- test/unit/test_import_buffer.rb
|
406
407
|
- test/unit/test_logger.rb
|
407
|
-
- test/unit/test_models.rb
|
408
408
|
- test/unit/test_runner.rb
|
409
409
|
- test/unit/test_scheduler.rb
|
410
410
|
- uploads/.gitignore
|
data/test/unit/test_models.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
module CouplerUnitTests
|
4
|
-
class TestModels < Coupler::Test::UnitTest
|
5
|
-
def test_lazy_loading_accepts_strings
|
6
|
-
assert_nothing_raised do
|
7
|
-
# This happens because Forgery calls const_missing directly with a string
|
8
|
-
Models.const_missing("Resource")
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|