r10k 1.4.2 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +2 -0
- data/CHANGELOG.mkd +192 -0
- data/CONTRIBUTING.mkd +3 -3
- data/Gemfile +4 -0
- data/README.mkd +13 -6
- data/doc/dynamic-environments/configuration.mkd +77 -8
- data/doc/dynamic-environments/git-environments.mkd +12 -2
- data/doc/dynamic-environments/quickstart.mkd +6 -0
- data/doc/faq.mkd +6 -6
- data/doc/git/cloning-and-mirroring.mkd +60 -0
- data/doc/git/providers.mkd +68 -0
- data/integration/Gemfile +3 -0
- data/integration/README.mkd +29 -0
- data/integration/configs/README.mkd +7 -0
- data/integration/configs/pe/centos-6-64mda +25 -0
- data/integration/configs/pe/centos-7-64mda +25 -0
- data/integration/configs/pe/debian-6-64mda +25 -0
- data/integration/configs/pe/debian-7-64mda +25 -0
- data/integration/configs/pe/redhat-6-64mda +25 -0
- data/integration/configs/pe/redhat-7-64mda +25 -0
- data/integration/configs/pe/sles-11-64mda +25 -0
- data/integration/configs/pe/ubuntu-1004-64mda +25 -0
- data/integration/configs/pe/ubuntu-1204-64mda +25 -0
- data/integration/configs/pe/ubuntu-1404-64mda +25 -0
- data/integration/files/README.mkd +4 -0
- data/integration/files/hiera.yaml +8 -0
- data/integration/files/modules/helloworld/manifests/init.pp +3 -0
- data/integration/files/modules/hieratest/manifests/init.pp +3 -0
- data/integration/files/modules/unicode/files/pretend_unicode +1 -0
- data/integration/files/modules/unicode/manifests/init.pp +6 -0
- data/integration/files/pre-suite/prod_env.config +3 -0
- data/integration/files/r10k_conf.yaml.erb +9 -0
- data/integration/lib/README.mkd +4 -0
- data/integration/lib/git_utils.rb +205 -0
- data/integration/lib/master_manipulator.rb +205 -0
- data/integration/lib/r10k_utils.rb +166 -0
- data/integration/manifests/README.mkd +4 -0
- data/integration/pre-suite/00_pe_install.rb +4 -0
- data/integration/pre-suite/01_git_config.rb +59 -0
- data/integration/pre-suite/02_pe_r10k.rb +60 -0
- data/integration/pre-suite/03_test_utils.rb +17 -0
- data/integration/pre-suite/README.mkd +5 -0
- data/integration/test_run_scripts/README.mkd +5 -0
- data/integration/test_run_scripts/all_tests-rugged-pe-centos6.sh +20 -0
- data/integration/test_run_scripts/all_tests-rugged-pe-rhel7.sh +20 -0
- data/integration/test_run_scripts/all_tests-rugged-pe-sles11.sh +20 -0
- data/integration/test_run_scripts/all_tests-rugged-pe-ubuntu1204.sh +20 -0
- data/integration/test_run_scripts/all_tests-rugged-pe-ubuntu1404.sh +20 -0
- data/integration/test_run_scripts/all_tests-shellgit-pe-centos6.sh +20 -0
- data/integration/test_run_scripts/all_tests-shellgit-pe-rhel7.sh +20 -0
- data/integration/test_run_scripts/all_tests-shellgit-pe-sles11.sh +20 -0
- data/integration/test_run_scripts/all_tests-shellgit-pe-ubuntu1204.sh +20 -0
- data/integration/test_run_scripts/all_tests-shellgit-pe-ubuntu1404.sh +20 -0
- data/integration/test_run_scripts/basic_functionality/all_tests-pe-centos6.sh +20 -0
- data/integration/test_run_scripts/command_line/all_tests-pe-centos6.sh +20 -0
- data/integration/test_run_scripts/git_source/all_tests-pe-centos6.sh +20 -0
- data/integration/test_run_scripts/user_scenario/basic_workflow/all_tests-pe-centos6.sh +20 -0
- data/integration/test_run_scripts/user_scenario/complex_workflow/all_tests-pe-centos6.sh +20 -0
- data/integration/tests/README.mkd +4 -0
- data/integration/tests/basic_functionality/negative/neg_deploy_with_invalid_r10k_yaml.rb +46 -0
- data/integration/tests/basic_functionality/negative/neg_deploy_with_missing_r10k_yaml.rb +27 -0
- data/integration/tests/command_line/deploy_env_without_mod_update.rb +75 -0
- data/integration/tests/command_line/negative/neg_deploy_env_with_module_update.rb +76 -0
- data/integration/tests/command_line/negative/neg_invalid_cli_dep_flag.rb +22 -0
- data/integration/tests/command_line/negative/neg_invalid_cli_env_flag.rb +22 -0
- data/integration/tests/command_line/negative/neg_invalid_cmd_line_arg.rb +24 -0
- data/integration/tests/git_source/git_source_git.rb +123 -0
- data/integration/tests/git_source/git_source_ssh.rb +84 -0
- data/integration/tests/git_source/git_source_submodule.rb +69 -0
- data/integration/tests/git_source/negative/neg_git_broken_remote.rb +37 -0
- data/integration/tests/git_source/negative/neg_git_unauthorized_https.rb +45 -0
- data/integration/tests/git_source/negative/neg_git_unauthorized_ssh.rb +72 -0
- data/integration/tests/git_source/negative/neg_git_unicode_branch.rb +34 -0
- data/integration/tests/user_scenario/basic_workflow/multi_env_1000_branches.rb +66 -0
- data/integration/tests/user_scenario/basic_workflow/multi_env_custom_forge_git_module.rb +110 -0
- data/integration/tests/user_scenario/basic_workflow/multi_env_custom_forge_git_module_static.rb +113 -0
- data/integration/tests/user_scenario/basic_workflow/multi_env_hiera.rb +93 -0
- data/integration/tests/user_scenario/basic_workflow/multi_env_multi_source.rb +132 -0
- data/integration/tests/user_scenario/basic_workflow/multi_source_custom_forge_git_module.rb +160 -0
- data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_basedir.rb +45 -0
- data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_forge_module.rb +43 -0
- data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_git_module.rb +40 -0
- data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_git_module_ref.rb +42 -0
- data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_git_remote.rb +44 -0
- data/integration/tests/user_scenario/basic_workflow/negative/neg_branch_name_collision.rb +63 -0
- data/integration/tests/user_scenario/basic_workflow/negative/neg_disk_full.rb +73 -0
- data/integration/tests/user_scenario/basic_workflow/negative/neg_duplicate_module_names.rb +45 -0
- data/integration/tests/user_scenario/basic_workflow/negative/neg_inaccessible_forge.rb +51 -0
- data/integration/tests/user_scenario/basic_workflow/negative/neg_invalid_env_name.rb +33 -0
- data/integration/tests/user_scenario/basic_workflow/negative/neg_invalid_puppet_file.rb +35 -0
- data/integration/tests/user_scenario/basic_workflow/negative/neg_module_specified_at_deleted_release.rb +44 -0
- data/integration/tests/user_scenario/basic_workflow/negative/neg_read_only.rb +57 -0
- data/integration/tests/user_scenario/basic_workflow/negative/neg_specify_deleted_forge_module.rb +44 -0
- data/integration/tests/user_scenario/basic_workflow/single_env_10000_files.rb +73 -0
- data/integration/tests/user_scenario/basic_workflow/single_env_custom_forge_git_module.rb +103 -0
- data/integration/tests/user_scenario/basic_workflow/single_env_custom_forge_module.rb +80 -0
- data/integration/tests/user_scenario/basic_workflow/single_env_custom_module.rb +48 -0
- data/integration/tests/user_scenario/basic_workflow/single_env_large_files.rb +73 -0
- data/integration/tests/user_scenario/basic_workflow/single_env_module_already_installed.rb +81 -0
- data/integration/tests/user_scenario/basic_workflow/single_env_module_last_release_deleted.rb +67 -0
- data/integration/tests/user_scenario/basic_workflow/single_env_non-existent_base_dir.rb +93 -0
- data/integration/tests/user_scenario/basic_workflow/single_env_purge_unmanaged_modules.rb +92 -0
- data/integration/tests/user_scenario/basic_workflow/single_env_switch_forge_git_module.rb +116 -0
- data/integration/tests/user_scenario/basic_workflow/single_env_unicode_paths.rb +59 -0
- data/integration/tests/user_scenario/basic_workflow/single_env_upgrade_forge_mod_revert_change.rb +165 -0
- data/integration/tests/user_scenario/complex_workflow/multi_env_add_change_remove.rb +162 -0
- data/integration/tests/user_scenario/complex_workflow/multi_env_remove_re-add.rb +110 -0
- data/lib/r10k/action/cri_runner.rb +10 -13
- data/lib/r10k/cli.rb +3 -8
- data/lib/r10k/cli/version.rb +10 -1
- data/lib/r10k/deployment/config.rb +26 -6
- data/lib/r10k/deployment/config/loader.rb +38 -29
- data/lib/r10k/deployment/source.rb +2 -4
- data/lib/r10k/environment/git.rb +10 -19
- data/lib/r10k/environment/name.rb +86 -0
- data/lib/r10k/errors.rb +8 -5
- data/lib/r10k/feature.rb +35 -0
- data/lib/r10k/feature/collection.rb +23 -0
- data/lib/r10k/features.rb +18 -0
- data/lib/r10k/git.rb +106 -12
- data/lib/r10k/git/alternates.rb +2 -2
- data/lib/r10k/git/cache.rb +43 -26
- data/lib/r10k/git/errors.rb +12 -6
- data/lib/r10k/git/head.rb +3 -0
- data/lib/r10k/git/ref.rb +3 -0
- data/lib/r10k/git/remote_head.rb +6 -0
- data/lib/r10k/git/repository.rb +6 -0
- data/lib/r10k/git/rugged.rb +17 -0
- data/lib/r10k/git/rugged/bare_repository.rb +86 -0
- data/lib/r10k/git/rugged/base_repository.rb +90 -0
- data/lib/r10k/git/rugged/cache.rb +11 -0
- data/lib/r10k/git/rugged/thin_repository.rb +72 -0
- data/lib/r10k/git/rugged/working_repository.rb +99 -0
- data/lib/r10k/git/shellgit.rb +9 -0
- data/lib/r10k/git/shellgit/bare_repository.rb +29 -0
- data/lib/r10k/git/shellgit/base_repository.rb +102 -0
- data/lib/r10k/git/shellgit/cache.rb +11 -0
- data/lib/r10k/git/shellgit/thin_repository.rb +56 -0
- data/lib/r10k/git/shellgit/working_repository.rb +73 -0
- data/lib/r10k/git/stateful_repository.rb +80 -0
- data/lib/r10k/git/tag.rb +3 -0
- data/lib/r10k/git/working_dir.rb +15 -2
- data/lib/r10k/logging.rb +73 -36
- data/lib/r10k/logging/terminaloutputter.rb +36 -0
- data/lib/r10k/module/forge.rb +10 -9
- data/lib/r10k/module/git.rb +14 -44
- data/lib/r10k/module/metadata_file.rb +31 -0
- data/lib/r10k/module/svn.rb +0 -1
- data/lib/r10k/module_repository/forge.rb +20 -7
- data/lib/r10k/puppetfile.rb +1 -1
- data/lib/r10k/settings/container.rb +6 -0
- data/lib/r10k/settings/mixin.rb +9 -0
- data/lib/r10k/source.rb +2 -3
- data/lib/r10k/source/base.rb +5 -5
- data/lib/r10k/source/git.rb +11 -86
- data/lib/r10k/source/svn.rb +8 -52
- data/lib/r10k/util/basedir.rb +4 -4
- data/lib/r10k/util/commands.rb +31 -0
- data/lib/r10k/util/exec_env.rb +36 -0
- data/lib/r10k/util/platform.rb +4 -0
- data/lib/r10k/util/purgeable.rb +2 -2
- data/lib/r10k/util/subprocess.rb +3 -7
- data/lib/r10k/util/subprocess/runner.rb +3 -28
- data/lib/r10k/util/subprocess/runner/posix.rb +103 -0
- data/lib/r10k/util/subprocess/runner/pump.rb +59 -0
- data/lib/r10k/util/subprocess/{windows/runner.rb → runner/windows.rb} +2 -11
- data/lib/r10k/util/symbolize_keys.rb +31 -0
- data/lib/r10k/version.rb +1 -1
- data/lib/shared/puppet/module_tool/metadata.rb +197 -0
- data/r10k.gemspec +7 -5
- data/spec/fixtures/integration/git/puppet-boolean-bare.tar +0 -0
- data/spec/fixtures/module/forge/bad_module/metadata.json +1 -0
- data/spec/fixtures/unit/util/subprocess/posix/runner/no-execute.sh +3 -0
- data/spec/fixtures/vcr/cassettes/R10K_ModuleRepository_Forge/and_the_expected_version_is_latest/can_fetch_all_versions_of_a_given_module.yml +171 -26
- data/spec/fixtures/vcr/cassettes/R10K_ModuleRepository_Forge/and_the_expected_version_is_latest/can_fetch_the_latest_version_of_a_given_module.yml +171 -26
- data/spec/fixtures/vcr/cassettes/R10K_ModuleRepository_Forge/and_the_expected_version_is_latest/ignores_deleted_releases.yml +190 -0
- data/spec/fixtures/vcr/cassettes/R10K_ModuleRepository_Forge/it_handles_errors_from_forgeapi_puppetlabs_com/raises_an_error_for_a_non-existant_module.yml +34 -0
- data/spec/fixtures/vcr/cassettes/R10K_Module_Forge/and_the_expected_version_is_latest/sets_the_expected_version_based_on_the_latest_forge_version.yml +87 -26
- data/spec/integration/git/rugged/bare_repository_spec.rb +13 -0
- data/spec/integration/git/rugged/thin_repository_spec.rb +14 -0
- data/spec/integration/git/rugged/working_repository_spec.rb +13 -0
- data/spec/integration/git/shellgit/bare_repository_spec.rb +13 -0
- data/spec/integration/git/shellgit/thin_repository_spec.rb +14 -0
- data/spec/integration/git/shellgit/working_repository_spec.rb +13 -0
- data/spec/integration/git/stateful_repository_spec.rb +104 -0
- data/spec/matchers/match_realpath.rb +18 -0
- data/spec/shared-contexts/git-fixtures.rb +55 -0
- data/spec/shared-examples/git-repository.rb +38 -0
- data/spec/shared-examples/git/bare_repository.rb +70 -0
- data/spec/shared-examples/git/thin_repository.rb +26 -0
- data/spec/shared-examples/git/working_repository.rb +115 -0
- data/spec/shared-examples/subprocess-runner.rb +83 -0
- data/spec/spec_helper.rb +13 -9
- data/spec/unit/action/cri_runner_spec.rb +0 -6
- data/spec/unit/action/puppetfile/{cri_action_spec.rb → cri_runner_spec.rb} +0 -0
- data/spec/unit/deployment/config/loader_spec.rb +48 -0
- data/spec/unit/deployment/config_spec.rb +49 -0
- data/spec/unit/environment/git_spec.rb +5 -39
- data/spec/unit/environment/name_spec.rb +135 -0
- data/spec/unit/feature_spec.rb +50 -0
- data/spec/unit/git/alternates_spec.rb +1 -1
- data/spec/unit/git/cache_spec.rb +32 -19
- data/spec/unit/git/commit_spec.rb +1 -0
- data/spec/unit/git/head_spec.rb +1 -6
- data/spec/unit/git/ref_spec.rb +0 -23
- data/spec/unit/git/rugged/cache_spec.rb +26 -0
- data/spec/unit/git/shellgit/cache_spec.rb +27 -0
- data/spec/unit/git/stateful_repository_spec.rb +43 -0
- data/spec/unit/git/tag_spec.rb +1 -0
- data/spec/unit/git/working_dir_spec.rb +1 -0
- data/spec/unit/git_spec.rb +74 -0
- data/spec/unit/logging/terminaloutputter_spec.rb +53 -0
- data/spec/unit/logging_spec.rb +68 -0
- data/spec/unit/module/forge_spec.rb +7 -38
- data/spec/unit/module/git_spec.rb +7 -38
- data/spec/unit/module/metadata_file_spec.rb +69 -0
- data/spec/unit/module/svn_spec.rb +0 -4
- data/spec/unit/module_repository/forge_spec.rb +22 -1
- data/spec/unit/puppet/module_tool/metadata_spec.rb +301 -0
- data/spec/unit/settings/container_spec.rb +17 -0
- data/spec/unit/source/git_spec.rb +0 -123
- data/spec/unit/source/svn_spec.rb +66 -0
- data/spec/unit/util/commands_spec.rb +61 -0
- data/spec/unit/util/exec_env_spec.rb +56 -0
- data/spec/unit/util/subprocess/runner/posix_spec.rb +7 -0
- data/spec/unit/util/subprocess/runner/pump_spec.rb +79 -0
- data/spec/unit/util/subprocess_spec.rb +3 -2
- data/spec/unit/util/symbolize_keys_spec.rb +51 -0
- metadata +226 -45
- data/lib/r10k/execution.rb +0 -47
- data/lib/r10k/module/metadata.rb +0 -47
- data/lib/r10k/util/core_ext/hash_ext.rb +0 -19
- data/lib/r10k/util/subprocess/io.rb +0 -7
- data/lib/r10k/util/subprocess/posix.rb +0 -4
- data/lib/r10k/util/subprocess/posix/io.rb +0 -7
- data/lib/r10k/util/subprocess/posix/runner.rb +0 -140
- data/lib/r10k/util/subprocess/windows.rb +0 -4
- data/lib/r10k/util/subprocess/windows/io.rb +0 -6
- data/spec/fixtures/vcr/cassettes/R10K_ModuleRepository_Forge/looking_up_versions.yml +0 -42
- data/spec/fixtures/vcr/cassettes/R10K_ModuleRepository_Forge/looking_up_versions/can_fetch_all_versions_of_a_given_module.yml +0 -42
- data/spec/fixtures/vcr/cassettes/R10K_ModuleRepository_Forge/looking_up_versions/can_fetch_the_latest_version_of_a_given_module.yml +0 -42
- data/spec/unit/deployment/source_spec.rb +0 -24
- data/spec/unit/module/metadata_spec.rb +0 -68
- data/spec/unit/util/core_ext/hash_ext_spec.rb +0 -63
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'r10k/feature'
|
3
|
+
|
4
|
+
describe R10K::Feature do
|
5
|
+
describe "confining a feature to a library" do
|
6
|
+
it "is available if the library can be loaded" do
|
7
|
+
feature = described_class.new(:r10k, :libraries => 'r10k')
|
8
|
+
expect(feature.available?).to be_truthy
|
9
|
+
end
|
10
|
+
|
11
|
+
it "is unavailable if the library cannot be loaded" do
|
12
|
+
feature = described_class.new(:squidlibs, :libraries => 'squid/libs')
|
13
|
+
expect(feature.available?).to be_falsey
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "confining a feature to a block" do
|
18
|
+
it "is available if the block is true" do
|
19
|
+
feature = described_class.new(:blockfeature) { true }
|
20
|
+
expect(feature.available?).to be_truthy
|
21
|
+
end
|
22
|
+
|
23
|
+
it "is unavailable if the block is false" do
|
24
|
+
feature = described_class.new(:blockfeature) { false }
|
25
|
+
expect(feature.available?).to be_falsey
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "confining a feature to both a block and libraries" do
|
30
|
+
it "is unavailable if the block returns false and libraries are absent" do
|
31
|
+
feature = described_class.new(:nope, :libraries => 'nope/nope') { false }
|
32
|
+
expect(feature.available?).to be_falsey
|
33
|
+
end
|
34
|
+
|
35
|
+
it "is unavailable if the block returns true and libraries are absent" do
|
36
|
+
feature = described_class.new(:nope, :libraries => 'nope/nope') { true }
|
37
|
+
expect(feature.available?).to be_falsey
|
38
|
+
end
|
39
|
+
|
40
|
+
it "is unavailable if the block returns false and libraries are present" do
|
41
|
+
feature = described_class.new(:nope, :libraries => 'r10k') { false }
|
42
|
+
expect(feature.available?).to be_falsey
|
43
|
+
end
|
44
|
+
|
45
|
+
it "is available if the block returns true and libraries are present" do
|
46
|
+
feature = described_class.new(:yep, :libraries => 'r10k') { true }
|
47
|
+
expect(feature.available?).to be_truthy
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -3,7 +3,7 @@ require 'stringio'
|
|
3
3
|
require 'r10k/git'
|
4
4
|
|
5
5
|
describe R10K::Git::Alternates do
|
6
|
-
subject { described_class.new("/some/nonexistent/path/.git") }
|
6
|
+
subject { described_class.new(Pathname.new("/some/nonexistent/path/.git")) }
|
7
7
|
|
8
8
|
it "interacts with the alternates file in the given git repository" do
|
9
9
|
expect(subject.file.to_s).to eq("/some/nonexistent/path/.git/objects/info/alternates")
|
data/spec/unit/git/cache_spec.rb
CHANGED
@@ -3,36 +3,49 @@ require 'r10k/git/cache'
|
|
3
3
|
|
4
4
|
describe R10K::Git::Cache do
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
let(:subclass) do
|
7
|
+
Class.new(described_class) do
|
8
|
+
def self.bare_repository
|
9
|
+
Class.new { def initialize(*args) end }
|
10
|
+
end
|
11
|
+
end
|
10
12
|
end
|
11
13
|
|
14
|
+
subject { subclass.new('git://some/git/remote') }
|
15
|
+
|
12
16
|
describe "updating the cache" do
|
13
17
|
it "only updates the cache once" do
|
14
|
-
expect(
|
15
|
-
|
16
|
-
|
18
|
+
expect(subject).to receive(:sync!).exactly(1).times
|
19
|
+
subject.sync
|
20
|
+
subject.sync
|
17
21
|
end
|
18
22
|
end
|
19
23
|
|
24
|
+
describe "methods on the repository" do
|
25
|
+
def expect_delegation(method)
|
26
|
+
expect(subject.repo).to receive(method)
|
27
|
+
subject.send(method)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "delegates #git_dir" do
|
31
|
+
expect_delegation(:git_dir)
|
32
|
+
end
|
20
33
|
|
21
|
-
|
22
|
-
|
23
|
-
%w[
|
24
|
-
refs/heads/master
|
25
|
-
refs/heads/next
|
26
|
-
refs/heads/next-fetch-errors
|
27
|
-
refs/heads/next-update-forge-modules
|
28
|
-
].map { |line| line + "\n" }.join
|
34
|
+
it "delegates #branches" do
|
35
|
+
expect_delegation(:branches)
|
29
36
|
end
|
30
37
|
|
31
|
-
it "
|
32
|
-
|
38
|
+
it "delegates #tags" do
|
39
|
+
expect_delegation(:tags)
|
40
|
+
end
|
33
41
|
|
34
|
-
|
42
|
+
it "delegates #exist?" do
|
43
|
+
expect_delegation(:exist?)
|
35
44
|
end
|
36
|
-
end
|
37
45
|
|
46
|
+
it "aliases #cached? to #exist?" do
|
47
|
+
expect(subject.repo).to receive(:exist?)
|
48
|
+
subject.cached?
|
49
|
+
end
|
50
|
+
end
|
38
51
|
end
|
data/spec/unit/git/head_spec.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'r10k/git'
|
3
|
+
require 'r10k/git/head'
|
3
4
|
|
4
5
|
describe R10K::Git::Head do
|
5
6
|
|
@@ -7,11 +8,6 @@ describe R10K::Git::Head do
|
|
7
8
|
let(:repo) { double('git repository') }
|
8
9
|
subject { described_class.new(ref) }
|
9
10
|
|
10
|
-
|
11
|
-
describe "determining if the head can be resolved" do
|
12
|
-
it "is always false"
|
13
|
-
end
|
14
|
-
|
15
11
|
describe "determining if the head needs to be fetched" do
|
16
12
|
it "is always true" do
|
17
13
|
expect(subject.fetch?).to be_truthy
|
@@ -24,4 +20,3 @@ describe R10K::Git::Head do
|
|
24
20
|
|
25
21
|
it_behaves_like "a git ref"
|
26
22
|
end
|
27
|
-
|
data/spec/unit/git/ref_spec.rb
CHANGED
@@ -37,29 +37,6 @@ describe R10K::Git::Ref do
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
describe "determining if the ref can be resolved" do
|
41
|
-
describe "and the ref is a head" do
|
42
|
-
it "is always false"
|
43
|
-
end
|
44
|
-
|
45
|
-
describe "and the ref is a tag" do
|
46
|
-
it "is true if the tag has been fetched"
|
47
|
-
it "is false if the tag cannot be resolved"
|
48
|
-
end
|
49
|
-
|
50
|
-
describe "and the ref is a commit" do
|
51
|
-
it "is true if the commit has been fetched"
|
52
|
-
it "is false if the commit cannot be resolved"
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
describe "determining if the ref needs to be fetched" do
|
57
|
-
it "uses the result of #resolvable? if the ref is a tag"
|
58
|
-
it "uses the result of #resolvable? if the ref is a commit"
|
59
|
-
|
60
|
-
it "is true if the ref is a head"
|
61
|
-
end
|
62
|
-
|
63
40
|
it "can be converted to a string" do
|
64
41
|
expect(subject.to_s).to eq ref
|
65
42
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'r10k/git/rugged/cache'
|
3
|
+
|
4
|
+
describe R10K::Git::Rugged::Cache do
|
5
|
+
subject(:cache) { described_class.new('git://some/git/remote') }
|
6
|
+
|
7
|
+
it "wraps a Rugged::BareRepository instance" do
|
8
|
+
expect(cache.repo).to be_a_kind_of R10K::Git::Rugged::BareRepository
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "settings" do
|
12
|
+
before do
|
13
|
+
R10K::Git::Cache.settings[:cache_root] = '/some/path'
|
14
|
+
described_class.settings.reset!
|
15
|
+
end
|
16
|
+
|
17
|
+
after do
|
18
|
+
R10K::Git::Cache.settings.reset!
|
19
|
+
described_class.settings.reset!
|
20
|
+
end
|
21
|
+
|
22
|
+
it "falls back to the parent class settings" do
|
23
|
+
expect(described_class.settings[:cache_root]).to eq '/some/path'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'r10k/git/shellgit/cache'
|
3
|
+
|
4
|
+
describe R10K::Git::ShellGit::Cache do
|
5
|
+
|
6
|
+
subject { described_class.new('git://some/git/remote') }
|
7
|
+
|
8
|
+
it "wraps a ShellGit::BareRepository instance" do
|
9
|
+
expect(subject.repo).to be_a_kind_of R10K::Git::ShellGit::BareRepository
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "settings" do
|
13
|
+
before do
|
14
|
+
R10K::Git::Cache.settings[:cache_root] = '/some/path'
|
15
|
+
described_class.settings.reset!
|
16
|
+
end
|
17
|
+
|
18
|
+
after do
|
19
|
+
R10K::Git::Cache.settings.reset!
|
20
|
+
described_class.settings.reset!
|
21
|
+
end
|
22
|
+
|
23
|
+
it "falls back to the parent class settings" do
|
24
|
+
expect(described_class.settings[:cache_root]).to eq '/some/path'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'r10k/git'
|
3
|
+
require 'r10k/git/stateful_repository'
|
4
|
+
|
5
|
+
describe R10K::Git::StatefulRepository do
|
6
|
+
|
7
|
+
let(:remote) { 'git://some.site/some-repo.git' }
|
8
|
+
|
9
|
+
subject { described_class.new('0.9.x', remote, '/some/nonexistent/basedir', 'some-dirname') }
|
10
|
+
|
11
|
+
describe "determining if the cache needs to be synced" do
|
12
|
+
|
13
|
+
let(:cache) { double('cache') }
|
14
|
+
|
15
|
+
before { expect(R10K::Git.cache).to receive(:generate).with(remote).and_return(cache) }
|
16
|
+
|
17
|
+
it "is true if the cache is absent" do
|
18
|
+
expect(cache).to receive(:exist?).and_return false
|
19
|
+
expect(subject.sync_cache?).to eq true
|
20
|
+
end
|
21
|
+
|
22
|
+
it "is true if the ref is unresolvable" do
|
23
|
+
expect(cache).to receive(:exist?).and_return true
|
24
|
+
expect(cache).to receive(:resolve).with('0.9.x')
|
25
|
+
expect(subject.sync_cache?).to eq true
|
26
|
+
end
|
27
|
+
|
28
|
+
it "is true if the ref is not a tag or commit" do
|
29
|
+
expect(cache).to receive(:exist?).and_return true
|
30
|
+
expect(cache).to receive(:resolve).with('0.9.x').and_return('93456ec7dc0f6fd3ac193b4df64f6544615dfbc9')
|
31
|
+
expect(cache).to receive(:ref_type).with('0.9.x').and_return(:branch)
|
32
|
+
expect(subject.sync_cache?).to eq true
|
33
|
+
end
|
34
|
+
|
35
|
+
it "is false otherwise" do
|
36
|
+
expect(cache).to receive(:exist?).and_return true
|
37
|
+
expect(cache).to receive(:resolve).with('0.9.x').and_return('93456ec7dc0f6fd3ac193b4df64f6544615dfbc9')
|
38
|
+
expect(cache).to receive(:ref_type).with('0.9.x').and_return(:tag)
|
39
|
+
expect(subject.sync_cache?).to eq false
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
data/spec/unit/git/tag_spec.rb
CHANGED
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'r10k/git'
|
3
|
+
|
4
|
+
describe R10K::Git do
|
5
|
+
before { described_class.reset! }
|
6
|
+
after { described_class.reset! }
|
7
|
+
|
8
|
+
describe 'selecting the default provider' do
|
9
|
+
it 'returns shellgit when the git executable is present' do
|
10
|
+
expect(R10K::Features).to receive(:available?).with(:shellgit).and_return true
|
11
|
+
expect(described_class.default).to eq R10K::Git::ShellGit
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'returns rugged when the git executable is absent and the rugged library is present' do
|
15
|
+
expect(R10K::Features).to receive(:available?).with(:shellgit).and_return false
|
16
|
+
expect(R10K::Features).to receive(:available?).with(:rugged).and_return true
|
17
|
+
expect(described_class.default).to eq R10K::Git::Rugged
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'raises an error when the git executable and rugged library are absent' do
|
21
|
+
expect(R10K::Features).to receive(:available?).with(:shellgit).and_return false
|
22
|
+
expect(R10K::Features).to receive(:available?).with(:rugged).and_return false
|
23
|
+
expect {
|
24
|
+
described_class.default
|
25
|
+
}.to raise_error(R10K::Error, 'No Git providers are functional.')
|
26
|
+
end
|
27
|
+
|
28
|
+
it "goes into an error state if an invalid provider was set" do
|
29
|
+
begin
|
30
|
+
described_class.provider = :nope
|
31
|
+
rescue R10K::Error
|
32
|
+
end
|
33
|
+
|
34
|
+
expect {
|
35
|
+
described_class.provider
|
36
|
+
}.to raise_error(R10K::Error, "No Git provider set.")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe 'explicitly setting the provider' do
|
41
|
+
it "raises an error if the provider doesn't exist" do
|
42
|
+
expect {
|
43
|
+
described_class.provider = :nope
|
44
|
+
}.to raise_error(R10K::Error, "No Git provider named 'nope'.")
|
45
|
+
end
|
46
|
+
|
47
|
+
it "raises an error if the provider isn't functional" do
|
48
|
+
expect(R10K::Features).to receive(:available?).with(:shellgit).and_return false
|
49
|
+
expect {
|
50
|
+
described_class.provider = :shellgit
|
51
|
+
}.to raise_error(R10K::Error, "Git provider 'shellgit' is not functional.")
|
52
|
+
end
|
53
|
+
|
54
|
+
it "sets the current provider if the provider exists and is functional" do
|
55
|
+
expect(R10K::Features).to receive(:available?).with(:rugged).and_return true
|
56
|
+
described_class.provider = :rugged
|
57
|
+
expect(described_class.provider).to eq(R10K::Git::Rugged)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "retrieving the current provider" do
|
62
|
+
it "uses the default if a provider has not been set" do
|
63
|
+
expect(described_class).to receive(:default).and_return :def
|
64
|
+
expect(described_class.provider).to eq :def
|
65
|
+
end
|
66
|
+
|
67
|
+
it "uses an explicitly set provider" do
|
68
|
+
expect(R10K::Features).to receive(:available?).with(:rugged).and_return true
|
69
|
+
described_class.provider = :rugged
|
70
|
+
expect(described_class).to_not receive(:default)
|
71
|
+
expect(described_class.provider).to eq R10K::Git::Rugged
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'stringio'
|
3
|
+
require 'r10k/logging/terminaloutputter'
|
4
|
+
|
5
|
+
describe R10K::Logging::TerminalOutputter do
|
6
|
+
|
7
|
+
let(:stream) { StringIO.new }
|
8
|
+
|
9
|
+
let(:formatter) do
|
10
|
+
Class.new(Log4r::Formatter) do
|
11
|
+
def format(logevent)
|
12
|
+
logevent.data
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
subject do
|
18
|
+
described_class.new('test', stream, :level => 0, :formatter => formatter).tap do |o|
|
19
|
+
o.use_color = true
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
tests = [
|
24
|
+
[:debug2, :cyan],
|
25
|
+
[:debug1, :cyan],
|
26
|
+
[:debug, :green],
|
27
|
+
[:info, nil],
|
28
|
+
[:notice, nil],
|
29
|
+
[:warn, :yellow],
|
30
|
+
[:error, :red],
|
31
|
+
[:fatal, :red],
|
32
|
+
]
|
33
|
+
|
34
|
+
tests.each_with_index do |(level, color), index|
|
35
|
+
# Note for the unwary - using a loop in this manner shows strange
|
36
|
+
# behavior with variable closure. The describe block is needed to retain
|
37
|
+
# the loop variables for each test; without this the let helpers are
|
38
|
+
# overwritten and the last set of helpers are used for all tests.
|
39
|
+
describe "at level #{level}" do
|
40
|
+
let(:message) { "level #{level}: #{color}" }
|
41
|
+
|
42
|
+
let(:event) do
|
43
|
+
Log4r::LogEvent.new(index + 1, Log4r::Logger.new('test::logger'), nil, message)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "logs messages as #{color ? color : "uncolored"}" do
|
47
|
+
output = color.nil? ? message : message.send(color)
|
48
|
+
subject.send(level, event)
|
49
|
+
expect(stream.string).to eq output
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'r10k/logging'
|
3
|
+
|
4
|
+
describe R10K::Logging do
|
5
|
+
|
6
|
+
describe "parsing a log level" do
|
7
|
+
it "parses 'true:TrueClass' as INFO" do
|
8
|
+
expect(described_class.parse_level(true)).to eq Log4r::INFO
|
9
|
+
end
|
10
|
+
|
11
|
+
it "parses 'true:String' as nil" do
|
12
|
+
expect(described_class.parse_level("true")).to be_nil
|
13
|
+
end
|
14
|
+
|
15
|
+
it "parses a numeric string as an integer" do
|
16
|
+
expect(described_class.parse_level('2')).to eq 2
|
17
|
+
end
|
18
|
+
|
19
|
+
it "parses a log level string as a log level" do
|
20
|
+
expect(described_class.parse_level('debug')).to eq Log4r::DEBUG
|
21
|
+
end
|
22
|
+
|
23
|
+
it "returns nil when given an invalid log level" do
|
24
|
+
expect(described_class.parse_level('deblag')).to be_nil
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "setting the log level" do
|
29
|
+
after(:all) { R10K::Logging.level = 'warn' }
|
30
|
+
|
31
|
+
it "sets the outputter log level" do
|
32
|
+
expect(described_class.outputter).to receive(:level=).with(Log4r::DEBUG)
|
33
|
+
described_class.level = 'debug'
|
34
|
+
end
|
35
|
+
|
36
|
+
it "stores the new log level" do
|
37
|
+
allow(described_class.outputter).to receive(:level=)
|
38
|
+
described_class.level = 'debug'
|
39
|
+
expect(described_class.level).to eq(Log4r::DEBUG)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "raises an exception when given an invalid log level" do
|
43
|
+
expect {
|
44
|
+
described_class.level = 'deblag'
|
45
|
+
}.to raise_error(ArgumentError, /Invalid log level/)
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "switching the formatter" do
|
49
|
+
before do
|
50
|
+
allow(described_class.outputter).to receive(:level=)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "switches to the debug formatter if the new log level is debug or greater" do
|
54
|
+
debug_formatter = double('debug formatter')
|
55
|
+
expect(described_class).to receive(:debug_formatter).and_return(debug_formatter)
|
56
|
+
expect(described_class.outputter).to receive(:formatter=).with(debug_formatter)
|
57
|
+
described_class.level = 'debug'
|
58
|
+
end
|
59
|
+
|
60
|
+
it "switches to the default formatter if the new log level is info or less" do
|
61
|
+
default_formatter = double('default formatter')
|
62
|
+
expect(described_class).to receive(:default_formatter).and_return(default_formatter)
|
63
|
+
expect(described_class.outputter).to receive(:formatter=).with(default_formatter)
|
64
|
+
described_class.level = 'info'
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|