kpm 0.8.2 → 0.10.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.rubocop.yml +73 -8
- data/README.adoc +37 -2
- data/docker/docker-compose.ci.mysql.yml +21 -0
- data/kpm.gemspec +4 -3
- data/lib/kpm/account.rb +3 -2
- data/lib/kpm/coordinates.rb +4 -3
- data/lib/kpm/database.rb +3 -2
- data/lib/kpm/formatter.rb +2 -2
- data/lib/kpm/inspector.rb +2 -2
- data/lib/kpm/killbill_server_artifact.rb +19 -10
- data/lib/kpm/migrations.rb +18 -4
- data/lib/kpm/nexus_helper/actions.rb +9 -5
- data/lib/kpm/nexus_helper/cloudsmith_api_calls.rb +85 -0
- data/lib/kpm/nexus_helper/github_api_calls.rb +70 -0
- data/lib/kpm/nexus_helper/nexus_api_calls_v2.rb +79 -50
- data/lib/kpm/plugins_directory.yml +8 -4
- data/lib/kpm/plugins_manager.rb +12 -5
- data/lib/kpm/tasks.rb +23 -7
- data/lib/kpm/tenant_config.rb +1 -1
- data/lib/kpm/tomcat_manager.rb +1 -0
- data/lib/kpm/version.rb +1 -1
- data/pom.xml +211 -40
- data/spec/kpm/remote/base_artifact_spec.rb +15 -13
- data/spec/kpm/remote/base_installer_spec.rb +13 -13
- data/spec/kpm/remote/cloudsmith_api_calls_spec.rb +109 -0
- data/spec/kpm/remote/github_api_calls_spec.rb +40 -0
- data/spec/kpm/remote/installer_spec.rb +30 -30
- data/spec/kpm/remote/kaui_artifact_spec.rb +4 -4
- data/spec/kpm/remote/killbill_plugin_artifact_spec.rb +19 -19
- data/spec/kpm/remote/killbill_server_artifact_spec.rb +13 -13
- data/spec/kpm/remote/migrations_spec.rb +9 -9
- data/spec/kpm/remote/nexus_facade_spec.rb +2 -2
- data/spec/kpm/remote/tenant_config_spec.rb +3 -3
- data/spec/kpm/remote/tomcat_manager_spec.rb +2 -2
- data/spec/kpm/unit/actions_spec.rb +2 -2
- data/spec/kpm/unit/base_artifact_spec.rb +14 -14
- data/spec/kpm/unit/inspector_spec.rb +28 -28
- data/spec/kpm/unit/installer_spec.rb +4 -4
- data/spec/kpm/unit/plugins_directory_spec.rb +31 -31
- data/spec/kpm/unit/plugins_manager_spec.rb +54 -54
- data/spec/kpm/unit/sha1_checker_spec.rb +2 -2
- data/spec/kpm/unit/uninstaller_spec.rb +21 -21
- data/spec/kpm/unit_mysql/account_spec.rb +13 -13
- data/spec/spec_helper.rb +1 -1
- metadata +27 -14
@@ -18,16 +18,16 @@ describe KPM::KillbillServerArtifact do
|
|
18
18
|
KPM::BaseArtifact::KILLBILL_CLASSIFIER,
|
19
19
|
'LATEST',
|
20
20
|
dir)
|
21
|
-
info[:file_name].
|
22
|
-
info[:size].
|
21
|
+
expect(info[:file_name]).to eq "killbill-profiles-killbill-#{info[:version]}.war"
|
22
|
+
expect(info[:size]).to eq File.size(info[:file_path])
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'should be able to list versions' do
|
27
27
|
versions = KPM::KillbillServerArtifact.versions(KPM::BaseArtifact::KILLBILL_ARTIFACT_ID).to_a
|
28
28
|
expect(versions.size).to be >= 2
|
29
|
-
versions[0].
|
30
|
-
versions[1].
|
29
|
+
expect(versions[0]).to eq '0.11.10'
|
30
|
+
expect(versions[1]).to eq '0.11.11'
|
31
31
|
end
|
32
32
|
|
33
33
|
it 'should get dependencies information' do
|
@@ -36,23 +36,23 @@ describe KPM::KillbillServerArtifact do
|
|
36
36
|
Dir.mktmpdir do |dir|
|
37
37
|
sha1_file = "#{dir}/sha1.yml"
|
38
38
|
info = KPM::KillbillServerArtifact.info('0.15.9', sha1_file)
|
39
|
-
info['killbill'].
|
40
|
-
info['killbill-oss-parent'].
|
41
|
-
info['killbill-api'].
|
42
|
-
info['killbill-plugin-api'].
|
43
|
-
info['killbill-commons'].
|
44
|
-
info['killbill-platform'].
|
45
|
-
KPM::Sha1Checker.from_file(sha1_file).killbill_info('0.15.9').
|
39
|
+
expect(info['killbill']).to eq '0.15.9'
|
40
|
+
expect(info['killbill-oss-parent']).to eq '0.62'
|
41
|
+
expect(info['killbill-api']).to eq '0.27'
|
42
|
+
expect(info['killbill-plugin-api']).to eq '0.16'
|
43
|
+
expect(info['killbill-commons']).to eq '0.10'
|
44
|
+
expect(info['killbill-platform']).to eq '0.13'
|
45
|
+
expect(KPM::Sha1Checker.from_file(sha1_file).killbill_info('0.15.9')).to eq info
|
46
46
|
|
47
47
|
# Verify the download is skipped gracefully when Nexus isn't reachable
|
48
48
|
KPM::KillbillServerArtifact.info('0.15.9', sha1_file, false, nil, nexus_down)
|
49
49
|
|
50
50
|
# Verify the download fails when Nexus isn't reachable and force_download is set
|
51
|
-
expect { KPM::KillbillServerArtifact.info('0.15.9', sha1_file, true, nil, nexus_down) }.to
|
51
|
+
expect { KPM::KillbillServerArtifact.info('0.15.9', sha1_file, true, nil, nexus_down) }.to raise_exception(SocketError, /(Failed to open TCP connection to does.not.exist:443|getaddrinfo)/)
|
52
52
|
|
53
53
|
# Verify the download fails when Nexus isn't reachable and the Nexus cache is empty
|
54
54
|
KPM::Sha1Checker.from_file(sha1_file).cache_killbill_info('0.15.9', nil)
|
55
|
-
expect { KPM::KillbillServerArtifact.info('0.15.9', sha1_file, false, nil, nexus_down) }.to
|
55
|
+
expect { KPM::KillbillServerArtifact.info('0.15.9', sha1_file, false, nil, nexus_down) }.to raise_exception(SocketError, /(Failed to open TCP connection to does.not.exist:443|getaddrinfo)/)
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|
@@ -7,13 +7,13 @@ describe KPM::Migrations, skip_me_if_nil: ENV['TOKEN'].nil? do
|
|
7
7
|
it 'should be able to find migrations for a java plugin' do
|
8
8
|
migrations = KPM::Migrations.new('analytics-plugin-3.0.2', nil, 'killbill/killbill-analytics-plugin', ENV['TOKEN']).migrations
|
9
9
|
# No migration yet
|
10
|
-
migrations.size.
|
10
|
+
expect(migrations.size).to eq 0
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'should be able to find migrations for a ruby plugin' do
|
14
14
|
migrations = KPM::Migrations.new('master', nil, 'killbill/killbill-cybersource-plugin', ENV['TOKEN']).migrations
|
15
15
|
# No migration yet
|
16
|
-
migrations.size.
|
16
|
+
expect(migrations.size).to eq 1
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -21,19 +21,19 @@ describe KPM::Migrations, skip_me_if_nil: ENV['TOKEN'].nil? do
|
|
21
21
|
it 'should be able to find migrations between two versions' do
|
22
22
|
migrations = KPM::Migrations.new('killbill-0.16.3', 'killbill-0.16.4', 'killbill/killbill', ENV['TOKEN']).migrations
|
23
23
|
|
24
|
-
migrations.size.
|
25
|
-
migrations.first[:name].
|
26
|
-
migrations.first[:sql].
|
24
|
+
expect(migrations.size).to eq 1
|
25
|
+
expect(migrations.first[:name]).to eq 'V20160324060345__revisit_payment_methods_indexes_509.sql'
|
26
|
+
expect(migrations.first[:sql]).to eq "drop index payment_methods_active_accnt on payment_methods;\n"
|
27
27
|
|
28
|
-
KPM::Migrations.new('master', 'master', 'killbill/killbill', ENV['TOKEN']).migrations.size.
|
28
|
+
expect(KPM::Migrations.new('master', 'master', 'killbill/killbill', ENV['TOKEN']).migrations.size).to eq 0
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'should be able to find migrations for a given version' do
|
32
32
|
migrations = KPM::Migrations.new('killbill-0.16.4', nil, 'killbill/killbill', ENV['TOKEN']).migrations
|
33
33
|
|
34
|
-
migrations.size.
|
35
|
-
migrations.first[:name].
|
36
|
-
migrations.first[:sql].
|
34
|
+
expect(migrations.size).to eq 1
|
35
|
+
expect(migrations.first[:name]).to eq 'V20160324060345__revisit_payment_methods_indexes_509.sql'
|
36
|
+
expect(migrations.first[:sql]).to eq "drop index payment_methods_active_accnt on payment_methods;\n"
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
@@ -51,7 +51,7 @@ describe KPM::NexusFacade do
|
|
51
51
|
destination = Dir.mktmpdir('artifact')
|
52
52
|
expect { response = nexus_remote.pull_artifact(coordinates, destination) }.not_to raise_exception
|
53
53
|
destination = File.join(File.expand_path(destination), response[:file_name])
|
54
|
-
expect(File.exist?(destination)).to
|
54
|
+
expect(File.exist?(destination)).to be_truthy
|
55
55
|
end
|
56
56
|
|
57
57
|
it 'when pull artifact with classifier' do
|
@@ -59,6 +59,6 @@ describe KPM::NexusFacade do
|
|
59
59
|
destination = Dir.mktmpdir('artifact')
|
60
60
|
expect { response = nexus_remote.pull_artifact(coordinates_with_classifier, destination) }.not_to raise_exception
|
61
61
|
destination = File.join(File.expand_path(destination), response[:file_name])
|
62
|
-
expect(File.exist?(destination)).to
|
62
|
+
expect(File.exist?(destination)).to be_truthy
|
63
63
|
end
|
64
64
|
end
|
@@ -29,7 +29,7 @@ describe KPM::TenantConfig do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'when initialized with options' do
|
32
|
-
tenant_config_class.
|
32
|
+
expect(tenant_config_class).to be_an_instance_of(KPM::TenantConfig)
|
33
33
|
expect(tenant_config_class.instance_variable_get(:@killbill_api_key)).to eq(killbill_api_key)
|
34
34
|
expect(tenant_config_class.instance_variable_get(:@killbill_api_secret)).to eq(killbill_api_secret)
|
35
35
|
expect(tenant_config_class.instance_variable_get(:@killbill_user)).to eq(killbill_user)
|
@@ -49,8 +49,8 @@ describe KPM::TenantConfig do
|
|
49
49
|
|
50
50
|
# get created tenant config
|
51
51
|
export_file = tenant_config_class.export(key)
|
52
|
-
expect(File.exist?(export_file)).to
|
53
|
-
expect(File.readlines(export_file).grep(/#{key}/)).to
|
52
|
+
expect(File.exist?(export_file)).to be_truthy
|
53
|
+
expect(File.readlines(export_file).grep(/#{key}/)).to be_truthy
|
54
54
|
|
55
55
|
# remove created tenant config
|
56
56
|
KillBillClient::Model::Tenant.delete_tenant_user_key_value(key, user, nil, nil, options)
|
@@ -13,10 +13,10 @@ describe KPM::TomcatManager do
|
|
13
13
|
manager = KPM::TomcatManager.new(dir, @logger)
|
14
14
|
|
15
15
|
tomcat_path = manager.download
|
16
|
-
tomcat_path.
|
16
|
+
expect(tomcat_path).not_to be_nil
|
17
17
|
|
18
18
|
root_war_path = manager.setup
|
19
|
-
root_war_path.
|
19
|
+
expect(root_war_path).not_to be_nil
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -8,7 +8,7 @@ describe KPM::NexusFacade::Actions do
|
|
8
8
|
let(:nexus_mock) { double(KPM::NexusFacade::NexusApiCallsV2) }
|
9
9
|
|
10
10
|
before do
|
11
|
-
KPM::NexusFacade::NexusApiCallsV2.
|
11
|
+
allow(KPM::NexusFacade::NexusApiCallsV2).to receive(:new).and_return(nexus_mock)
|
12
12
|
end
|
13
13
|
|
14
14
|
context 'when Nexus throws a non-retryable exception' do
|
@@ -45,7 +45,7 @@ describe KPM::NexusFacade::Actions do
|
|
45
45
|
raise OpenSSL::SSL::SSLErrorWaitReadable if calls < 2
|
46
46
|
|
47
47
|
true
|
48
|
-
end).to
|
48
|
+
end).to be_truthy
|
49
49
|
expect(calls).to eq(2)
|
50
50
|
end
|
51
51
|
end
|
@@ -14,16 +14,16 @@ describe KPM::BaseArtifact do
|
|
14
14
|
Dir.mktmpdir do |dir|
|
15
15
|
info = KPM::BaseArtifact.pull_from_fs(@logger, file_path, dir)
|
16
16
|
|
17
|
-
info[:skipped].
|
18
|
-
info[:is_tgz].
|
19
|
-
info[:repository_path].
|
20
|
-
info[:dir_name].
|
21
|
-
info[:bundle_dir].
|
22
|
-
info[:file_name].
|
17
|
+
expect(info[:skipped]).to be_falsey
|
18
|
+
expect(info[:is_tgz]).to be_falsey
|
19
|
+
expect(info[:repository_path]).to eq file_path
|
20
|
+
expect(info[:dir_name]).to eq dir
|
21
|
+
expect(info[:bundle_dir]).to eq dir
|
22
|
+
expect(info[:file_name]).to eq 'sha1_test.yml'
|
23
23
|
|
24
24
|
files_in_dir = Dir[dir + '/*']
|
25
|
-
files_in_dir.size.
|
26
|
-
files_in_dir[0].
|
25
|
+
expect(files_in_dir.size).to eq 1
|
26
|
+
expect(files_in_dir[0]).to eq info[:file_path]
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
@@ -83,11 +83,11 @@ describe KPM::BaseArtifact do
|
|
83
83
|
|
84
84
|
KPM::BaseArtifact.send('populate_fs_info', info, specified_destination_path)
|
85
85
|
|
86
|
-
info[:repository_path].
|
87
|
-
info[:is_tgz].
|
88
|
-
info[:version].
|
89
|
-
info[:dir_name].
|
90
|
-
info[:file_name].
|
91
|
-
info[:file_path].
|
86
|
+
expect(info[:repository_path]).to eq repository_path
|
87
|
+
expect(info[:is_tgz]).to eq is_tgz
|
88
|
+
expect(info[:version]).to eq version
|
89
|
+
expect(info[:dir_name]).to eq expected_dir_name
|
90
|
+
expect(info[:file_name]).to eq expected_file_name
|
91
|
+
expect(info[:file_path]).to eq expected_file_path
|
92
92
|
end
|
93
93
|
end
|
@@ -31,34 +31,34 @@ describe KPM::Inspector do
|
|
31
31
|
|
32
32
|
inspector = KPM::Inspector.new
|
33
33
|
all_plugins = inspector.inspect(@bundles_dir)
|
34
|
-
all_plugins.size.
|
35
|
-
|
36
|
-
all_plugins['plugin_bar'][:plugin_key].
|
37
|
-
all_plugins['plugin_bar'][:plugin_path].
|
38
|
-
all_plugins['plugin_bar'][:versions].size.
|
39
|
-
all_plugins['plugin_bar'][:versions][0][:version].
|
40
|
-
all_plugins['plugin_bar'][:versions][0][:is_default].
|
41
|
-
all_plugins['plugin_bar'][:versions][0][:is_disabled].
|
42
|
-
all_plugins['plugin_bar'][:versions][0][:sha1].
|
43
|
-
|
44
|
-
all_plugins['plugin_foo'][:plugin_key].
|
45
|
-
all_plugins['plugin_foo'][:plugin_path].
|
46
|
-
all_plugins['plugin_foo'][:versions].size.
|
47
|
-
|
48
|
-
all_plugins['plugin_foo'][:versions][0][:version].
|
49
|
-
all_plugins['plugin_foo'][:versions][0][:is_default].
|
50
|
-
all_plugins['plugin_foo'][:versions][0][:is_disabled].
|
51
|
-
all_plugins['plugin_foo'][:versions][0][:sha1].
|
52
|
-
|
53
|
-
all_plugins['plugin_foo'][:versions][1][:version].
|
54
|
-
all_plugins['plugin_foo'][:versions][1][:is_default].
|
55
|
-
all_plugins['plugin_foo'][:versions][1][:is_disabled].
|
56
|
-
all_plugins['plugin_foo'][:versions][1][:sha1].
|
57
|
-
|
58
|
-
all_plugins['plugin_foo'][:versions][2][:version].
|
59
|
-
all_plugins['plugin_foo'][:versions][2][:is_default].
|
60
|
-
all_plugins['plugin_foo'][:versions][2][:is_disabled].
|
61
|
-
all_plugins['plugin_foo'][:versions][2][:sha1].
|
34
|
+
expect(all_plugins.size).to eq 2
|
35
|
+
|
36
|
+
expect(all_plugins['plugin_bar'][:plugin_key]).to eq 'bar'
|
37
|
+
expect(all_plugins['plugin_bar'][:plugin_path]).to eq @java_plugins_dir.join('plugin_bar').to_s
|
38
|
+
expect(all_plugins['plugin_bar'][:versions].size).to eq 1
|
39
|
+
expect(all_plugins['plugin_bar'][:versions][0][:version]).to eq '1.0.0'
|
40
|
+
expect(all_plugins['plugin_bar'][:versions][0][:is_default]).to eq false
|
41
|
+
expect(all_plugins['plugin_bar'][:versions][0][:is_disabled]).to eq false
|
42
|
+
expect(all_plugins['plugin_bar'][:versions][0][:sha1]).to eq '98765'
|
43
|
+
|
44
|
+
expect(all_plugins['plugin_foo'][:plugin_key]).to eq 'foo'
|
45
|
+
expect(all_plugins['plugin_foo'][:plugin_path]).to eq @ruby_plugins_dir.join('plugin_foo').to_s
|
46
|
+
expect(all_plugins['plugin_foo'][:versions].size).to eq 3
|
47
|
+
|
48
|
+
expect(all_plugins['plugin_foo'][:versions][0][:version]).to eq '1.2.3'
|
49
|
+
expect(all_plugins['plugin_foo'][:versions][0][:is_default]).to eq false
|
50
|
+
expect(all_plugins['plugin_foo'][:versions][0][:is_disabled]).to eq true
|
51
|
+
expect(all_plugins['plugin_foo'][:versions][0][:sha1]).to eq '12345'
|
52
|
+
|
53
|
+
expect(all_plugins['plugin_foo'][:versions][1][:version]).to eq '2.0.0'
|
54
|
+
expect(all_plugins['plugin_foo'][:versions][1][:is_default]).to eq false
|
55
|
+
expect(all_plugins['plugin_foo'][:versions][1][:is_disabled]).to eq false
|
56
|
+
expect(all_plugins['plugin_foo'][:versions][1][:sha1]).to eq '23456'
|
57
|
+
|
58
|
+
expect(all_plugins['plugin_foo'][:versions][2][:version]).to eq '2.0.1'
|
59
|
+
expect(all_plugins['plugin_foo'][:versions][2][:is_default]).to eq true
|
60
|
+
expect(all_plugins['plugin_foo'][:versions][2][:is_disabled]).to eq false
|
61
|
+
expect(all_plugins['plugin_foo'][:versions][2][:sha1]).to eq '34567'
|
62
62
|
end
|
63
63
|
|
64
64
|
private
|
@@ -8,11 +8,11 @@ describe KPM::Installer do
|
|
8
8
|
|
9
9
|
it 'finds the right stable versions' do
|
10
10
|
config = KPM::Installer.build_default_config(all_kb_versions)
|
11
|
-
config['killbill'].
|
12
|
-
config['killbill']['version'].
|
11
|
+
expect(config['killbill']).not_to be_nil
|
12
|
+
expect(config['killbill']['version']).to eq '0.16.11'
|
13
13
|
|
14
|
-
config['kaui'].
|
15
|
-
config['kaui']['version'].
|
14
|
+
expect(config['kaui']).not_to be_nil
|
15
|
+
expect(config['kaui']['version']).to eq 'LATEST'
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -5,48 +5,48 @@ require 'spec_helper'
|
|
5
5
|
describe KPM::PluginsDirectory do
|
6
6
|
it 'should parse the plugins directory' do
|
7
7
|
directory = KPM::PluginsDirectory.all(false)
|
8
|
-
directory.size.
|
8
|
+
expect(directory.size).to be > 0
|
9
9
|
end
|
10
10
|
|
11
11
|
it 'should lookup plugins' do
|
12
12
|
group_id, artifact_id, packaging, classifier, version, type = KPM::PluginsDirectory.lookup('analytics', false, '0.20.11')
|
13
|
-
group_id.
|
14
|
-
artifact_id.
|
15
|
-
packaging.
|
16
|
-
classifier.
|
17
|
-
version.
|
18
|
-
type.
|
13
|
+
expect(group_id).to eq 'org.kill-bill.billing.plugin.java'
|
14
|
+
expect(artifact_id).to eq 'analytics-plugin'
|
15
|
+
expect(packaging).to eq 'jar'
|
16
|
+
expect(classifier).to be_nil
|
17
|
+
expect(version).to eq '6.0.1'
|
18
|
+
expect(type).to eq :java
|
19
19
|
|
20
20
|
group_id, artifact_id, packaging, classifier, version, type = KPM::PluginsDirectory.lookup('analytics', false, '0.20.11-SNAPSHOT')
|
21
|
-
group_id.
|
22
|
-
artifact_id.
|
23
|
-
packaging.
|
24
|
-
classifier.
|
25
|
-
version.
|
26
|
-
type.
|
21
|
+
expect(group_id).to eq 'org.kill-bill.billing.plugin.java'
|
22
|
+
expect(artifact_id).to eq 'analytics-plugin'
|
23
|
+
expect(packaging).to eq 'jar'
|
24
|
+
expect(classifier).to be_nil
|
25
|
+
expect(version).to eq '6.0.1'
|
26
|
+
expect(type).to eq :java
|
27
27
|
|
28
28
|
group_id, artifact_id, packaging, classifier, version, type = KPM::PluginsDirectory.lookup('analytics', false, '0.20')
|
29
|
-
group_id.
|
30
|
-
artifact_id.
|
31
|
-
packaging.
|
32
|
-
classifier.
|
33
|
-
version.
|
34
|
-
type.
|
29
|
+
expect(group_id).to eq 'org.kill-bill.billing.plugin.java'
|
30
|
+
expect(artifact_id).to eq 'analytics-plugin'
|
31
|
+
expect(packaging).to eq 'jar'
|
32
|
+
expect(classifier).to be_nil
|
33
|
+
expect(version).to eq '6.0.1'
|
34
|
+
expect(type).to eq :java
|
35
35
|
|
36
36
|
group_id, artifact_id, packaging, classifier, version, type = KPM::PluginsDirectory.lookup('analytics', false, 'LATEST')
|
37
|
-
group_id.
|
38
|
-
artifact_id.
|
39
|
-
packaging.
|
40
|
-
classifier.
|
41
|
-
version.
|
42
|
-
type.
|
37
|
+
expect(group_id).to eq 'org.kill-bill.billing.plugin.java'
|
38
|
+
expect(artifact_id).to eq 'analytics-plugin'
|
39
|
+
expect(packaging).to eq 'jar'
|
40
|
+
expect(classifier).to be_nil
|
41
|
+
expect(version).to eq 'LATEST'
|
42
|
+
expect(type).to eq :java
|
43
43
|
|
44
44
|
group_id, artifact_id, packaging, classifier, version, type = KPM::PluginsDirectory.lookup('analytics', false, '0.42')
|
45
|
-
group_id.
|
46
|
-
artifact_id.
|
47
|
-
packaging.
|
48
|
-
classifier.
|
49
|
-
version.
|
50
|
-
type.
|
45
|
+
expect(group_id).to eq 'org.kill-bill.billing.plugin.java'
|
46
|
+
expect(artifact_id).to eq 'analytics-plugin'
|
47
|
+
expect(packaging).to eq 'jar'
|
48
|
+
expect(classifier).to be_nil
|
49
|
+
expect(version).to eq 'LATEST'
|
50
|
+
expect(type).to eq :java
|
51
51
|
end
|
52
52
|
end
|
@@ -15,7 +15,7 @@ describe KPM::PluginsManager do
|
|
15
15
|
FileUtils.mkdir_p(@plugin_dir.join('1.0.0'))
|
16
16
|
FileUtils.mkdir_p(@plugin_dir.join('2.0.0'))
|
17
17
|
|
18
|
-
File.exist?(@plugin_dir.join('SET_DEFAULT')).
|
18
|
+
expect(File.exist?(@plugin_dir.join('SET_DEFAULT'))).to be_falsey
|
19
19
|
end
|
20
20
|
|
21
21
|
after(:each) do
|
@@ -25,74 +25,74 @@ describe KPM::PluginsManager do
|
|
25
25
|
it 'creates a plugin identifier entry with no coordinate' do
|
26
26
|
# Verifies file gets created if does not exist
|
27
27
|
identifiers = @manager.add_plugin_identifier_key('foo', 'foo_name', 'type', nil)
|
28
|
-
identifiers.size.
|
29
|
-
identifiers['foo']['plugin_name'].
|
28
|
+
expect(identifiers.size).to eq 1
|
29
|
+
expect(identifiers['foo']['plugin_name']).to eq 'foo_name'
|
30
30
|
end
|
31
31
|
|
32
32
|
it 'creates a plugin identifier entry with coordinates' do
|
33
33
|
# Verifies file gets created if does not exist
|
34
34
|
coordinate_map = { group_id: 'group', artifact_id: 'artifact', packaging: 'packaging', version: 'version' }
|
35
35
|
identifiers = @manager.add_plugin_identifier_key('bar', 'bar_name', 'type', coordinate_map)
|
36
|
-
identifiers.size.
|
37
|
-
identifiers['bar']['plugin_name'].
|
38
|
-
identifiers['bar']['group_id'].
|
39
|
-
identifiers['bar']['artifact_id'].
|
40
|
-
identifiers['bar']['packaging'].
|
41
|
-
identifiers['bar']['classifier'].
|
42
|
-
identifiers['bar']['version'].
|
36
|
+
expect(identifiers.size).to eq 1
|
37
|
+
expect(identifiers['bar']['plugin_name']).to eq 'bar_name'
|
38
|
+
expect(identifiers['bar']['group_id']).to eq 'group'
|
39
|
+
expect(identifiers['bar']['artifact_id']).to eq 'artifact'
|
40
|
+
expect(identifiers['bar']['packaging']).to eq 'packaging'
|
41
|
+
expect(identifiers['bar']['classifier']).to be_nil
|
42
|
+
expect(identifiers['bar']['version']).to eq 'version'
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'creates plugin identifier with multiple entries' do
|
46
46
|
# Verifies file gets created if does not exist
|
47
47
|
identifiers = @manager.add_plugin_identifier_key('foo', 'foo_name', 'type', nil)
|
48
|
-
identifiers.size.
|
49
|
-
identifiers['foo']['plugin_name'].
|
48
|
+
expect(identifiers.size).to eq 1
|
49
|
+
expect(identifiers['foo']['plugin_name']).to eq 'foo_name'
|
50
50
|
|
51
51
|
# Verify file was created from previous entry (prev value was read)
|
52
52
|
identifiers = @manager.add_plugin_identifier_key('bar', 'bar_name', 'type', nil)
|
53
|
-
identifiers.size.
|
54
|
-
identifiers['foo']['plugin_name'].
|
55
|
-
identifiers['bar']['plugin_name'].
|
53
|
+
expect(identifiers.size).to eq 2
|
54
|
+
expect(identifiers['foo']['plugin_name']).to eq 'foo_name'
|
55
|
+
expect(identifiers['bar']['plugin_name']).to eq 'bar_name'
|
56
56
|
|
57
57
|
# Verify file was created from previous entry (prev value was read)
|
58
58
|
identifiers = @manager.add_plugin_identifier_key('zoe', 'zoe_name', 'type', nil)
|
59
|
-
identifiers.size.
|
60
|
-
identifiers['bar']['plugin_name'].
|
61
|
-
identifiers['foo']['plugin_name'].
|
62
|
-
identifiers['zoe']['plugin_name'].
|
59
|
+
expect(identifiers.size).to eq 3
|
60
|
+
expect(identifiers['bar']['plugin_name']).to eq 'bar_name'
|
61
|
+
expect(identifiers['foo']['plugin_name']).to eq 'foo_name'
|
62
|
+
expect(identifiers['zoe']['plugin_name']).to eq 'zoe_name'
|
63
63
|
end
|
64
64
|
|
65
65
|
it 'creates plugin identifiers with duplicate entries' do
|
66
66
|
# Verifies file gets created if does not exist
|
67
67
|
identifiers = @manager.add_plugin_identifier_key('kewl', 'kewl_name', 'type', nil)
|
68
|
-
identifiers.size.
|
69
|
-
identifiers['kewl']['plugin_name'].
|
68
|
+
expect(identifiers.size).to eq 1
|
69
|
+
expect(identifiers['kewl']['plugin_name']).to eq 'kewl_name'
|
70
70
|
|
71
71
|
# Add with a different plugin_name
|
72
72
|
identifiers = @manager.add_plugin_identifier_key('kewl', 'kewl_name2', 'type', nil)
|
73
|
-
identifiers.size.
|
74
|
-
identifiers['kewl']['plugin_name'].
|
73
|
+
expect(identifiers.size).to eq 1
|
74
|
+
expect(identifiers['kewl']['plugin_name']).to eq 'kewl_name'
|
75
75
|
end
|
76
76
|
|
77
77
|
it 'creates plugin identifiers and remove entry' do
|
78
78
|
# Verifies file gets created if does not exist
|
79
79
|
identifiers = @manager.add_plugin_identifier_key('lol', 'lol_name', 'type', nil)
|
80
|
-
identifiers.size.
|
81
|
-
identifiers['lol']['plugin_name'].
|
80
|
+
expect(identifiers.size).to eq 1
|
81
|
+
expect(identifiers['lol']['plugin_name']).to eq 'lol_name'
|
82
82
|
|
83
83
|
# Remove wrong entry, nothing happens
|
84
84
|
identifiers = @manager.remove_plugin_identifier_key('lol2')
|
85
|
-
identifiers.size.
|
86
|
-
identifiers['lol']['plugin_name'].
|
85
|
+
expect(identifiers.size).to eq 1
|
86
|
+
expect(identifiers['lol']['plugin_name']).to eq 'lol_name'
|
87
87
|
|
88
88
|
# Remove correct entry
|
89
89
|
identifiers = @manager.remove_plugin_identifier_key('lol')
|
90
|
-
identifiers.size.
|
90
|
+
expect(identifiers.size).to eq 0
|
91
91
|
|
92
92
|
# Add same entry again
|
93
93
|
identifiers = @manager.add_plugin_identifier_key('lol', 'lol_name', 'type', nil)
|
94
|
-
identifiers.size.
|
95
|
-
identifiers['lol']['plugin_name'].
|
94
|
+
expect(identifiers.size).to eq 1
|
95
|
+
expect(identifiers['lol']['plugin_name']).to eq 'lol_name'
|
96
96
|
end
|
97
97
|
|
98
98
|
it 'creates plugin identifiers and validate entry' do
|
@@ -100,15 +100,15 @@ describe KPM::PluginsManager do
|
|
100
100
|
coordinate_map = { group_id: 'group', artifact_id: 'artifact', packaging: 'packaging', version: 'version' }
|
101
101
|
|
102
102
|
identifiers = @manager.add_plugin_identifier_key('yoyo', 'yoyo_name', 'type', coordinate_map)
|
103
|
-
identifiers.size.
|
104
|
-
identifiers['yoyo']['plugin_name'].
|
103
|
+
expect(identifiers.size).to eq 1
|
104
|
+
expect(identifiers['yoyo']['plugin_name']).to eq 'yoyo_name'
|
105
105
|
|
106
|
-
@manager.validate_plugin_identifier_key('yoyo', coordinate_map).
|
106
|
+
expect(@manager.validate_plugin_identifier_key('yoyo', coordinate_map)).to eq true
|
107
107
|
|
108
108
|
# Negative validation
|
109
109
|
invalid_coordinate_map = { group_id: 'group1', artifact_id: 'artifact', packaging: 'packaging', version: 'version' }
|
110
110
|
|
111
|
-
@manager.validate_plugin_identifier_key('yoyo', invalid_coordinate_map).
|
111
|
+
expect(@manager.validate_plugin_identifier_key('yoyo', invalid_coordinate_map)).to eq false
|
112
112
|
end
|
113
113
|
|
114
114
|
it 'creates a plugin identifier entry with a new version' do
|
@@ -117,36 +117,36 @@ describe KPM::PluginsManager do
|
|
117
117
|
coordinate_map1 = { group_id: 'group', artifact_id: 'artifact', packaging: 'packaging', version: 'version1' }
|
118
118
|
|
119
119
|
identifiers = @manager.add_plugin_identifier_key('bar', 'bar_name', 'type', coordinate_map1)
|
120
|
-
identifiers.size.
|
121
|
-
identifiers['bar']['plugin_name'].
|
122
|
-
identifiers['bar']['version'].
|
120
|
+
expect(identifiers.size).to eq 1
|
121
|
+
expect(identifiers['bar']['plugin_name']).to eq 'bar_name'
|
122
|
+
expect(identifiers['bar']['version']).to eq 'version1'
|
123
123
|
|
124
124
|
coordinate_map2 = { group_id: 'group', artifact_id: 'artifact', packaging: 'packaging', version: 'version2' }
|
125
125
|
|
126
126
|
identifiers = @manager.add_plugin_identifier_key('bar', 'bar_name', 'type', coordinate_map2)
|
127
|
-
identifiers.size.
|
128
|
-
identifiers['bar']['plugin_name'].
|
129
|
-
identifiers['bar']['version'].
|
127
|
+
expect(identifiers.size).to eq 1
|
128
|
+
expect(identifiers['bar']['plugin_name']).to eq 'bar_name'
|
129
|
+
expect(identifiers['bar']['version']).to eq 'version2'
|
130
130
|
end
|
131
131
|
|
132
132
|
it 'sets a path as active' do
|
133
133
|
@manager.set_active(@plugin_dir.join('1.0.0'))
|
134
|
-
File.exist?(@plugin_dir.join('SET_DEFAULT')).
|
135
|
-
File.readlink(@plugin_dir.join('SET_DEFAULT')).
|
134
|
+
expect(File.exist?(@plugin_dir.join('SET_DEFAULT'))).to be_truthy
|
135
|
+
expect(File.readlink(@plugin_dir.join('SET_DEFAULT'))).to eq @plugin_dir.join('1.0.0').to_s
|
136
136
|
|
137
137
|
@manager.set_active(@plugin_dir.join('2.0.0'))
|
138
|
-
File.exist?(@plugin_dir.join('SET_DEFAULT')).
|
139
|
-
File.readlink(@plugin_dir.join('SET_DEFAULT')).
|
138
|
+
expect(File.exist?(@plugin_dir.join('SET_DEFAULT'))).to be_truthy
|
139
|
+
expect(File.readlink(@plugin_dir.join('SET_DEFAULT'))).to eq @plugin_dir.join('2.0.0').to_s
|
140
140
|
end
|
141
141
|
|
142
142
|
it 'sets a plugin version as active' do
|
143
143
|
@manager.set_active('killbill-stripe', '2.0.0')
|
144
|
-
File.exist?(@plugin_dir.join('SET_DEFAULT')).
|
145
|
-
File.readlink(@plugin_dir.join('SET_DEFAULT')).
|
144
|
+
expect(File.exist?(@plugin_dir.join('SET_DEFAULT'))).to be_truthy
|
145
|
+
expect(File.readlink(@plugin_dir.join('SET_DEFAULT'))).to eq @plugin_dir.join('2.0.0').to_s
|
146
146
|
|
147
147
|
@manager.set_active('killbill-stripe', '1.0.0')
|
148
|
-
File.exist?(@plugin_dir.join('SET_DEFAULT')).
|
149
|
-
File.readlink(@plugin_dir.join('SET_DEFAULT')).
|
148
|
+
expect(File.exist?(@plugin_dir.join('SET_DEFAULT'))).to be_truthy
|
149
|
+
expect(File.readlink(@plugin_dir.join('SET_DEFAULT'))).to eq @plugin_dir.join('1.0.0').to_s
|
150
150
|
end
|
151
151
|
|
152
152
|
it 'uninstalls a plugin via a path' do
|
@@ -190,19 +190,19 @@ describe KPM::PluginsManager do
|
|
190
190
|
end
|
191
191
|
|
192
192
|
it 'guesses the plugin name' do
|
193
|
-
@manager.guess_plugin_name('tripe').
|
193
|
+
expect(@manager.guess_plugin_name('tripe')).to be_nil
|
194
194
|
# Short name
|
195
|
-
@manager.guess_plugin_name('stripe').
|
195
|
+
expect(@manager.guess_plugin_name('stripe')).to eq 'killbill-stripe'
|
196
196
|
# Artifact id
|
197
|
-
@manager.guess_plugin_name('stripe-plugin').
|
197
|
+
expect(@manager.guess_plugin_name('stripe-plugin')).to eq 'killbill-stripe'
|
198
198
|
# Plugin name (top directory in the .tar.gz)
|
199
|
-
@manager.guess_plugin_name('killbill-stripe').
|
199
|
+
expect(@manager.guess_plugin_name('killbill-stripe')).to eq 'killbill-stripe'
|
200
200
|
end
|
201
201
|
|
202
202
|
private
|
203
203
|
|
204
204
|
def check_state(version, has_restart, has_disabled)
|
205
|
-
File.exist?(@plugin_dir.join(version).join('tmp').join('restart.txt')).
|
206
|
-
File.exist?(@plugin_dir.join(version).join('tmp').join('disabled.txt')).
|
205
|
+
expect(File.exist?(@plugin_dir.join(version).join('tmp').join('restart.txt'))).to eq has_restart
|
206
|
+
expect(File.exist?(@plugin_dir.join(version).join('tmp').join('disabled.txt'))).to eq has_disabled
|
207
207
|
end
|
208
208
|
end
|