cableguy 0.2.3 → 0.5.0.pre2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +59 -1
- data/Gemfile +6 -5
- data/Gemfile.lock +38 -0
- data/LICENSE.md +20 -0
- data/README.md +28 -0
- data/Rakefile +23 -1
- data/bin/cable +2 -37
- data/cableguy.gemspec +15 -17
- data/lib/palmade/cableguy/builders/cable_chmod.rb +3 -5
- data/lib/palmade/cableguy/builders/cable_copy.rb +2 -5
- data/lib/palmade/cableguy/builders/cable_custom.rb +6 -3
- data/lib/palmade/cableguy/builders/cable_mkdir.rb +3 -6
- data/lib/palmade/cableguy/builders/cable_move.rb +2 -5
- data/lib/palmade/cableguy/builders/cable_symlink.rb +4 -7
- data/lib/palmade/cableguy/builders/cable_template.rb +25 -9
- data/lib/palmade/cableguy/builders.rb +7 -8
- data/lib/palmade/cableguy/cable.rb +1 -24
- data/lib/palmade/cableguy/cablefile.rb +107 -0
- data/lib/palmade/cableguy/cabler.rb +257 -53
- data/lib/palmade/cableguy/cabling_values.rb +54 -0
- data/lib/palmade/cableguy/cli.rb +232 -0
- data/lib/palmade/cableguy/cli_helper.rb +18 -0
- data/lib/palmade/cableguy/configurator.rb +19 -20
- data/lib/palmade/cableguy/constants.rb +17 -2
- data/lib/palmade/cableguy/db.rb +115 -66
- data/lib/palmade/cableguy/{cable_configurator.rb → legacy_configurator.rb} +1 -2
- data/lib/palmade/cableguy/migration.rb +37 -61
- data/lib/palmade/cableguy/migrator.rb +124 -0
- data/lib/palmade/cableguy/templatebinding.rb +23 -16
- data/lib/palmade/cableguy/utils.rb +6 -7
- data/lib/palmade/cableguy/version.rb +1 -1
- data/lib/palmade/cableguy.rb +19 -34
- data/test/.cabling_values.yml +9 -0
- data/test/app/Cablefile +10 -0
- data/test/app/cabling/base/blog.rb +21 -0
- data/test/app/cabling/init.rb +16 -0
- data/test/app/config/templates/blog.yml +10 -0
- data/test/app_cabling_test.rb +33 -0
- data/test/boboot.rb +53 -0
- data/test/boot_test.rb +25 -0
- data/test/cablefile_test.rb +44 -0
- data/test/cabler_test.rb +45 -0
- data/test/cabling/base/blog.rb +17 -0
- data/test/cabling/init.rb +16 -0
- data/test/cabling_values_test.rb +24 -0
- data/test/cli_lock_test.rb +28 -0
- data/test/cli_test.rb +88 -0
- data/test/configure_test.rb +31 -0
- data/test/db_methods_test.rb +19 -0
- data/test/migrate_legacy_test.rb +34 -0
- data/test/migrate_test.rb +39 -0
- data/test/test_apply/config/blog.yml +10 -0
- data/test/test_helper.rb +81 -0
- metadata +93 -29
- data/Manifest +0 -19
- data/README +0 -1
- data/lib/palmade/cableguy/runner.rb +0 -44
@@ -1,12 +1,11 @@
|
|
1
1
|
module Palmade::Cableguy
|
2
2
|
class Utils
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
lower_case_and_underscored_word.to_s[0].chr.downcase + camelize(lower_case_and_underscored_word)[1..-1]
|
3
|
+
def self.symbolize_keys(hash)
|
4
|
+
hash.inject({ }) do |result, (key, value)|
|
5
|
+
new_key = key.kind_of?(String) ? key.to_sym : key
|
6
|
+
new_value = value.kind_of?(Hash) ? symbolize_keys(value) : value
|
7
|
+
result[new_key] = new_value
|
8
|
+
result
|
10
9
|
end
|
11
10
|
end
|
12
11
|
end
|
data/lib/palmade/cableguy.rb
CHANGED
@@ -1,43 +1,28 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'benchmark'
|
3
|
-
require 'fileutils'
|
4
|
-
require 'sequel'
|
5
|
-
require 'logger'
|
6
|
-
require File.join(File.dirname(__FILE__), 'cableguy/version')
|
7
|
-
|
8
1
|
module Palmade
|
9
2
|
module Cableguy
|
10
|
-
autoload :Builders,
|
11
|
-
autoload :Cable,
|
12
|
-
autoload :Cabler,
|
13
|
-
autoload :CableConfigurator, File.join(File.dirname(__FILE__), 'cableguy/cable_configurator')
|
14
|
-
autoload :Configurator, File.join(File.dirname(__FILE__), 'cableguy/configurator')
|
15
|
-
autoload :Constants, File.join(File.dirname(__FILE__), 'cableguy/constants')
|
16
|
-
autoload :DB, File.join(File.dirname(__FILE__), 'cableguy/db')
|
17
|
-
autoload :Migration, File.join(File.dirname(__FILE__), 'cableguy/migration')
|
18
|
-
autoload :Runner, File.join(File.dirname(__FILE__), 'cableguy/runner')
|
19
|
-
autoload :TemplateBinding, File.join(File.dirname(__FILE__), 'cableguy/templatebinding')
|
20
|
-
autoload :Utils, File.join(File.dirname(__FILE__), 'cableguy/utils')
|
3
|
+
autoload :Builders, 'palmade/cableguy/builders'
|
4
|
+
autoload :Cable, 'palmade/cableguy/cable'
|
5
|
+
autoload :Cabler, 'palmade/cableguy/cabler'
|
21
6
|
|
22
|
-
|
23
|
-
|
24
|
-
|
7
|
+
autoload :CLI, 'palmade/cableguy/cli'
|
8
|
+
autoload :CliHelper, 'palmade/cableguy/cli_helper'
|
9
|
+
autoload :Constants, 'palmade/cableguy/constants'
|
10
|
+
autoload :DB, 'palmade/cableguy/db'
|
11
|
+
autoload :CablingValues, 'palmade/cableguy/cabling_values'
|
12
|
+
autoload :Migrator, 'palmade/cableguy/migrator'
|
13
|
+
autoload :Migration, 'palmade/cableguy/migration'
|
14
|
+
autoload :Runner, 'palmade/cableguy/runner'
|
15
|
+
autoload :TemplateBinding, 'palmade/cableguy/templatebinding'
|
25
16
|
|
26
|
-
|
27
|
-
|
28
|
-
|
17
|
+
autoload :Configurator, 'palmade/cableguy/configurator'
|
18
|
+
autoload :LegacyConfigurator, 'palmade/cableguy/legacy_configurator'
|
19
|
+
autoload :Cablefile, 'palmade/cableguy/cablefile'
|
29
20
|
|
30
|
-
|
31
|
-
|
32
|
-
end
|
21
|
+
autoload :Utils, 'palmade/cableguy/utils'
|
22
|
+
autoload :VERSION, 'palmade/cableguy/version'
|
33
23
|
|
34
|
-
def self.
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
def self.require_erb
|
39
|
-
require 'erb'
|
24
|
+
def self.boot_cabler(app_path, opts = { })
|
25
|
+
Palmade::Cableguy::Cabler.new(app_path, opts).boot
|
40
26
|
end
|
41
27
|
end
|
42
28
|
end
|
43
|
-
|
data/test/app/Cablefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
module TestCableguyAppCabling::Base
|
2
|
+
class Blog < Palmade::Cableguy::Migration
|
3
|
+
def migrate!
|
4
|
+
group 'blog' do
|
5
|
+
set 'fb_oauth', 'true'
|
6
|
+
|
7
|
+
prefix 'mongo' do
|
8
|
+
set 'host', '127.0.0.1'
|
9
|
+
set 'port', '27019'
|
10
|
+
end
|
11
|
+
|
12
|
+
prefix 'db' do
|
13
|
+
set 'host', '192.168.0.1'
|
14
|
+
set 'port', '3307'
|
15
|
+
set 'username', 'user'
|
16
|
+
set 'password', ''
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# init file, that is loaded prior to loading the cabling files in this cabling directory.
|
2
|
+
# this can be used to load custom gems / ruby codes, etc, that you can use
|
3
|
+
# within your cabling files.
|
4
|
+
#
|
5
|
+
|
6
|
+
TEST_APP_CABLING_INIT_FILE_LOADED = true
|
7
|
+
|
8
|
+
module TestCableguyAppCabling
|
9
|
+
module Base
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
module Targets
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require File.expand_path('../test_helper', __FILE__)
|
2
|
+
require 'minitest/autorun'
|
3
|
+
|
4
|
+
class AppCablingTest < MiniTest::Test
|
5
|
+
include TestHelper
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@cabler = TestHelper.configure
|
9
|
+
@db = @cabler.db
|
10
|
+
@migrator = @cabler.migrator
|
11
|
+
@app_migrator = @cabler.app_migrator
|
12
|
+
|
13
|
+
@cabler.configure
|
14
|
+
end
|
15
|
+
|
16
|
+
def teardown
|
17
|
+
TestHelper.unload_cabling
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_app_cabling_path_is_set
|
21
|
+
assert_equal(@cabler.app_cabling_path, File.join(TestHelper::TEST_APP_ROOT, 'cabling'))
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_cabling_init_is_loaded
|
25
|
+
assert(defined?(TEST_APP_CABLING_INIT_FILE_LOADED), 'App cabling init not loaded')
|
26
|
+
assert_equal(true, TEST_APP_CABLING_INIT_FILE_LOADED)
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_blog_values_inserted
|
30
|
+
assert_equal('true', @db.get('fb_oauth', 'blog'))
|
31
|
+
assert_equal('127.0.0.1', @db.get('mongo.host', 'blog'))
|
32
|
+
end
|
33
|
+
end
|
data/test/boboot.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
ROOT_PATH = CABLEGUY_ROOT_PATH = File.expand_path('../..', __FILE__)
|
3
|
+
|
4
|
+
begin
|
5
|
+
require "rubygems"
|
6
|
+
require "bundler"
|
7
|
+
rescue LoadError
|
8
|
+
raise "Could not load the bundler gem. Install it with `gem install bundler`."
|
9
|
+
end
|
10
|
+
|
11
|
+
begin
|
12
|
+
# Set up load paths for all bundled gems
|
13
|
+
ENV["BUNDLE_GEMFILE"] = File.join(ROOT_PATH, 'Gemfile')
|
14
|
+
Bundler.setup
|
15
|
+
rescue Bundler::GemNotFound
|
16
|
+
raise RuntimeError, "Bundler couldn't find some gems." +
|
17
|
+
"Did you run bundle install?"
|
18
|
+
end
|
19
|
+
|
20
|
+
module Boboot
|
21
|
+
def self.root_path; ROOT_PATH; end
|
22
|
+
|
23
|
+
def self.add_lib_to_load_path
|
24
|
+
File.join(root_path, 'lib').tap { |p| $LOAD_PATH.unshift(p) unless $LOAD_PATH.include?(p) }
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.require_relative_gem(gem_name, lib_path)
|
28
|
+
require File.join(self.root_path, '..', gem_name, 'lib', lib_path)
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.disable_rubygem_warns
|
32
|
+
# Disables Rubygems warnings, as otherwise this is totally out of control
|
33
|
+
if (defined?(Deprecate))
|
34
|
+
Deprecate.skip = true
|
35
|
+
elsif (defined?(Gem::Deprecate))
|
36
|
+
Gem::Deprecate.skip = true
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.silence_warns
|
41
|
+
original_verbosity = $VERBOSE
|
42
|
+
$VERBOSE = nil
|
43
|
+
result = yield
|
44
|
+
$VERBOSE = original_verbosity
|
45
|
+
result
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
Boboot.disable_rubygem_warns
|
50
|
+
Boboot.add_lib_to_load_path
|
51
|
+
|
52
|
+
# explicitly disable warnings!
|
53
|
+
$VERBOSE = nil
|
data/test/boot_test.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.expand_path('../test_helper', __FILE__)
|
2
|
+
require 'minitest/autorun'
|
3
|
+
|
4
|
+
class BootTest < MiniTest::Test
|
5
|
+
def setup
|
6
|
+
@cabler = TestHelper.configure
|
7
|
+
end
|
8
|
+
|
9
|
+
def teardown
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_booted
|
14
|
+
assert_equal(@cabler.app_root, TestHelper::TEST_APP_ROOT)
|
15
|
+
assert_equal(@cabler.cabling_path, TestHelper::TEST_CABLING_PATH)
|
16
|
+
assert_equal(@cabler.target, :test)
|
17
|
+
assert_nil(@cabler.location)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_create_builtin_logger
|
21
|
+
refute_nil(@cabler.logger)
|
22
|
+
assert_respond_to(@cabler.logger, :log)
|
23
|
+
assert_respond_to(@cabler.logger, :add)
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require File.expand_path('../test_helper', __FILE__)
|
2
|
+
require 'minitest/autorun'
|
3
|
+
|
4
|
+
class CablefileTest < MiniTest::Test
|
5
|
+
def setup
|
6
|
+
subdir_app_root = File.join(TestHelper::TEST_APP_ROOT, 'config')
|
7
|
+
|
8
|
+
@cabler = TestHelper.configure
|
9
|
+
@cablefile = @cabler.cablefile
|
10
|
+
|
11
|
+
@cabler_sub = TestHelper.configure(subdir_app_root)
|
12
|
+
@cablefile_sub = @cabler_sub.cablefile
|
13
|
+
|
14
|
+
@db = @cabler.db
|
15
|
+
end
|
16
|
+
|
17
|
+
def teardown
|
18
|
+
TestHelper.unload_cabling
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_cablefile_path
|
22
|
+
correct_cablefile_path = File.join(TestHelper::TEST_APP_ROOT, 'Cablefile')
|
23
|
+
|
24
|
+
assert_equal(correct_cablefile_path, @cabler.cablefile.file_path)
|
25
|
+
assert_equal(correct_cablefile_path, @cabler_sub.cablefile.file_path)
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_app_root
|
29
|
+
assert_equal(@cabler.app_root, File.dirname(@cabler.cablefile.file_path))
|
30
|
+
assert_equal(@cabler_sub.app_root, File.dirname(@cabler_sub.cablefile.file_path))
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_is_configured
|
34
|
+
assert(@cabler.cablefile.configured?, 'Cablefile not configured!')
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_app_group_is_set
|
38
|
+
@group_stack = @db.instance_variable_get('@group_stack')
|
39
|
+
|
40
|
+
assert_equal('blog', @cabler.app_group)
|
41
|
+
assert_equal('blog', @group_stack[0])
|
42
|
+
assert_equal([ 'blog' ], @group_stack)
|
43
|
+
end
|
44
|
+
end
|
data/test/cabler_test.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require File.expand_path('../test_helper', __FILE__)
|
2
|
+
require 'minitest/autorun'
|
3
|
+
|
4
|
+
class CablerTest < MiniTest::Test
|
5
|
+
include TestHelper
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@cabler = TestHelper.configure
|
9
|
+
@cabler_with_apply = TestHelper.configure(nil, :apply_path => TEST_APPLY_ROOT)
|
10
|
+
@cabler_app_cabling_only = TestHelper.configure(nil, :include_global_cabling => false)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_apply_path
|
14
|
+
assert_nil(@cabler.apply_path)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_apply_path_is_app_root
|
18
|
+
assert_equal(@cabler.determine_apply_path, @cabler.app_root)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_apply_path_for_templates
|
22
|
+
assert_equal(@cabler.determine_apply_path(:for_templates => true),
|
23
|
+
File.join(@cabler.app_root, 'config'))
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_with_apply_path
|
27
|
+
refute_equal(@cabler_with_apply.determine_apply_path, @cabler_with_apply.app_root)
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_include_global_cabling_paths
|
31
|
+
cps = @cabler.send(:determine_useable_cabling_paths)
|
32
|
+
|
33
|
+
assert_includes(cps, TEST_CABLING_PATH)
|
34
|
+
assert_includes(cps, File.join(TEST_APP_ROOT, 'cabling'))
|
35
|
+
assert(cps.count, 2)
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_app_cabling_only
|
39
|
+
cps = @cabler_app_cabling_only.send(:determine_useable_cabling_paths)
|
40
|
+
|
41
|
+
refute_includes(cps, TEST_CABLING_PATH)
|
42
|
+
assert_includes(cps, File.join(TEST_APP_ROOT, 'cabling'))
|
43
|
+
assert(cps.count, 1)
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module TestCableguyCabling::Base
|
2
|
+
class Blog < Palmade::Cableguy::Migration
|
3
|
+
def migrate!
|
4
|
+
group 'blog' do
|
5
|
+
set 'require_2fa', 'true'
|
6
|
+
set 'twitter_auth', 'true'
|
7
|
+
|
8
|
+
prefix 'db' do
|
9
|
+
set 'host', '127.0.0.1'
|
10
|
+
set 'port', '3306'
|
11
|
+
set 'username', 'root'
|
12
|
+
set 'password', ''
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# init file, that is loaded prior to loading the cabling files in this cabling directory.
|
2
|
+
# this can be used to load custom gems / ruby codes, etc, that you can use
|
3
|
+
# within your cabling files.
|
4
|
+
#
|
5
|
+
|
6
|
+
TEST_CABLING_INIT_FILE_LOADED = true
|
7
|
+
|
8
|
+
module TestCableguyCabling
|
9
|
+
module Base
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
module Targets
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require File.expand_path('../test_helper', __FILE__)
|
2
|
+
require 'minitest/autorun'
|
3
|
+
|
4
|
+
class CablingValuesTest < MiniTest::Test
|
5
|
+
def setup
|
6
|
+
@cabler = TestHelper.configure
|
7
|
+
@cabler.configure
|
8
|
+
|
9
|
+
@db = @cabler.db
|
10
|
+
end
|
11
|
+
|
12
|
+
def teardown
|
13
|
+
TestHelper.unload_cabling
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_values_loaded
|
17
|
+
assert_equal('127.0.0.1', @cabler.values['redis']['host'])
|
18
|
+
assert_equal(6379, @cabler.values['redis']['port'])
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_password_value_override
|
22
|
+
assert_equal('password', @db.get('db.password', 'blog'))
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require File.expand_path('../test_helper', __FILE__)
|
2
|
+
require 'minitest/autorun'
|
3
|
+
|
4
|
+
class CliLockTest < MiniTest::Test
|
5
|
+
include Palmade::Cableguy::Constants
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@test_cli = TestHelper.new_cli_tester('configure', [ '--target=test' ])
|
9
|
+
@another_cli = TestHelper.new_cli_tester('configure', [ ])
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_lock_target
|
13
|
+
test_lock_opts = @test_cli.prepare_lock_file(:lock_no_persist => true)
|
14
|
+
assert_equal('test', test_lock_opts[:target])
|
15
|
+
|
16
|
+
test_cabler = @test_cli.cabler(:lock_no_persist => true)
|
17
|
+
assert_equal('test', test_cabler.target)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_lock_file_target
|
21
|
+
@test_cli.prepare_lock_file
|
22
|
+
|
23
|
+
lock_opts = @another_cli.prepare_lock_file
|
24
|
+
File.delete(@test_cli.lock_file_path)
|
25
|
+
|
26
|
+
assert_equal('test', lock_opts[:target])
|
27
|
+
end
|
28
|
+
end
|
data/test/cli_test.rb
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
require File.expand_path('../test_helper', __FILE__)
|
2
|
+
require 'minitest/autorun'
|
3
|
+
|
4
|
+
class CliTest < MiniTest::Test
|
5
|
+
include Palmade::Cableguy::Constants
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@cli = TestHelper.new_cli_tester('configure')
|
9
|
+
@lock_opts = @cli.prepare_lock_file
|
10
|
+
|
11
|
+
TestHelper.disable_default_cabling_path do
|
12
|
+
@cabler = @cli.cabler
|
13
|
+
end
|
14
|
+
|
15
|
+
@cabler.configure
|
16
|
+
|
17
|
+
@default_cli = TestHelper.new_cli_tester('configure', [ '--nolock' ])
|
18
|
+
|
19
|
+
TestHelper.disable_default_cabling_path do
|
20
|
+
@default_cabler = @default_cli.cabler
|
21
|
+
end
|
22
|
+
|
23
|
+
@default_db = @default_cabler.db
|
24
|
+
end
|
25
|
+
|
26
|
+
def teardown
|
27
|
+
TestHelper.unload_cabling
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_cabling_path_set
|
31
|
+
assert_equal(TestHelper::TEST_CABLING_PATH, @cabler.cabling_path)
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_cabling_values_path_set
|
35
|
+
assert_equal(TestHelper::TEST_CABLING_VALUES_PATH, @cabler.values_path)
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_app_root_is_set
|
39
|
+
assert_equal(TestHelper::TEST_APP_ROOT, @cabler.app_root)
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_cabling_defaults_set
|
43
|
+
if ENV.include?('CABLING_PATH')
|
44
|
+
default_path = File.expand_path(ENV['CABLING_PATH'])
|
45
|
+
elsif File.exists?(DEFAULT_CABLING_PATH)
|
46
|
+
default_path = File.expand_path(DEFAULT_CABLING_PATH)
|
47
|
+
else
|
48
|
+
default_path = nil
|
49
|
+
end
|
50
|
+
|
51
|
+
unless default_path.nil?
|
52
|
+
loop do
|
53
|
+
if File.symlink?(default_path)
|
54
|
+
default_path = File.readlink(default_path)
|
55
|
+
else
|
56
|
+
break
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
assert_equal(default_path, @default_cabler.cabling_path)
|
61
|
+
end
|
62
|
+
|
63
|
+
values_path = File.expand_path(DEFAULT_CABLING_VALUES_PATH)
|
64
|
+
if File.exists?(values_path)
|
65
|
+
assert_equal(values_path, @default_cabler.values_path)
|
66
|
+
else
|
67
|
+
assert_nil(@default_cabler.values_path, 'Default cabling values path is not nil')
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_cabling_defaults_will_raise_error
|
72
|
+
assert_raises(RuntimeError) do
|
73
|
+
@default_cabler.configure
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_cabling_defaults_db_empty
|
78
|
+
assert(@default_db.empty?, 'Default database not empty!')
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_lock_defaults_target
|
82
|
+
assert_equal(DEFAULT_TARGET, @lock_opts[:target])
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_lock_defaults_location
|
86
|
+
assert_nil(@lock_opts[:location])
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.expand_path('../test_helper', __FILE__)
|
2
|
+
require 'minitest/autorun'
|
3
|
+
|
4
|
+
class ConfigureTest < MiniTest::Test
|
5
|
+
include TestHelper
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@cabler = TestHelper.configure
|
9
|
+
@cabler.configure
|
10
|
+
@builds = @cabler.builds
|
11
|
+
|
12
|
+
TestHelper.unload_cabling
|
13
|
+
|
14
|
+
@cabler_with_apply = TestHelper.configure(nil, :apply_path => TEST_APPLY_ROOT)
|
15
|
+
@cabler_with_apply.configure
|
16
|
+
|
17
|
+
TestHelper.unload_cabling
|
18
|
+
end
|
19
|
+
|
20
|
+
def teardown
|
21
|
+
TestHelper.unload_cabling
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_built
|
25
|
+
assert(@builds.count > 0, 'No builds configured')
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_apply_path_different
|
29
|
+
refute_equal(@cabler_with_apply.determine_apply_path, @cabler_with_apply.app_root)
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.expand_path('../test_helper', __FILE__)
|
2
|
+
require 'minitest/autorun'
|
3
|
+
|
4
|
+
class DbMethodsTest < MiniTest::Test
|
5
|
+
def setup
|
6
|
+
@cabler = TestHelper.configure
|
7
|
+
@db = @cabler.db
|
8
|
+
end
|
9
|
+
|
10
|
+
def teardown
|
11
|
+
TestHelper.unload_cabling
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_data_methods
|
15
|
+
assert_respond_to(@db, :group)
|
16
|
+
assert_respond_to(@db, :prefix)
|
17
|
+
assert_respond_to(@db, :globals)
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require File.expand_path('../test_helper', __FILE__)
|
2
|
+
require 'minitest/autorun'
|
3
|
+
|
4
|
+
class MigrateLegacyTest < MiniTest::Test
|
5
|
+
def setup
|
6
|
+
@cabler = TestHelper.configure(nil, :save_db => true)
|
7
|
+
@db = @cabler.db
|
8
|
+
@save_db = @cabler.save_db
|
9
|
+
|
10
|
+
@migrate = @cabler.migrate
|
11
|
+
@migrator = @cabler.migrator
|
12
|
+
end
|
13
|
+
|
14
|
+
def teardown
|
15
|
+
TestHelper.unload_cabling
|
16
|
+
|
17
|
+
unless @save_db.nil?
|
18
|
+
File.delete(@save_db)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_migrator_created
|
23
|
+
refute_nil(@migrator, '@migrator not initiated')
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_migrate_migrated
|
27
|
+
assert(@db.migrated?, 'DB not migrated')
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_db_created
|
31
|
+
refute_nil(@save_db, 'SQLite DB not set')
|
32
|
+
assert(File.exists?(@save_db), 'SQLite DB not created')
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require File.expand_path('../test_helper', __FILE__)
|
2
|
+
require 'minitest/autorun'
|
3
|
+
|
4
|
+
class MigrateTest < MiniTest::Test
|
5
|
+
def setup
|
6
|
+
@cabler = TestHelper.configure(nil, :unload_cabling => false)
|
7
|
+
@db = @cabler.db
|
8
|
+
@migrate = @cabler.migrate
|
9
|
+
@migrator = @cabler.migrator
|
10
|
+
end
|
11
|
+
|
12
|
+
def teardown
|
13
|
+
TestHelper.unload_cabling
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_cabling_init_is_loaded
|
17
|
+
assert(defined?(TEST_CABLING_INIT_FILE_LOADED), 'Cabling init not loaded')
|
18
|
+
assert_equal(true, TEST_CABLING_INIT_FILE_LOADED)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_cabling_blog_loaded
|
22
|
+
assert(defined?(TestCableguyCabling::Base::Blog), 'Base::Blog expected from cabling not loaded')
|
23
|
+
assert_includes(@migrator.klass_stack, TestCableguyCabling::Base::Blog)
|
24
|
+
assert_equal(@migrator.klass_stack, [ TestCableguyCabling::Base::Blog ])
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_blog_values_inserted
|
28
|
+
assert_equal('true', @db.get('require_2fa', 'blog'))
|
29
|
+
assert_equal('true', @db.get('twitter_auth', 'blog'))
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_migration_instantiated
|
33
|
+
refute_empty(@migrator.instance_stack)
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_cabling_path_values_are_retained
|
37
|
+
assert_equal('127.0.0.1', @db.get('db.host', 'blog'))
|
38
|
+
end
|
39
|
+
end
|