gooddata 1.0.2-java → 1.1.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/CONTRIBUTING.md +12 -0
- data/README.md +5 -2
- data/Rakefile +0 -1
- data/dev-gooddata-sso.pub.encrypted +40 -0
- data/gooddata.gemspec +3 -3
- data/lib/gooddata/connection.rb +23 -13
- data/lib/gooddata/helpers/data_helper.rb +0 -1
- data/lib/gooddata/lcm/actions/apply_custom_maql.rb +8 -1
- data/lib/gooddata/lcm/actions/associate_clients.rb +8 -1
- data/lib/gooddata/lcm/actions/base_action.rb +10 -0
- data/lib/gooddata/lcm/actions/collect_ca_metrics.rb +7 -1
- data/lib/gooddata/lcm/actions/collect_client_projects.rb +3 -0
- data/lib/gooddata/lcm/actions/collect_clients.rb +3 -1
- data/lib/gooddata/lcm/actions/collect_data_product.rb +10 -2
- data/lib/gooddata/lcm/actions/collect_dynamic_schedule_params.rb +12 -1
- data/lib/gooddata/lcm/actions/collect_ldm_objects.rb +6 -2
- data/lib/gooddata/lcm/actions/collect_meta.rb +1 -1
- data/lib/gooddata/lcm/actions/collect_segment_clients.rb +8 -1
- data/lib/gooddata/lcm/actions/collect_segments.rb +6 -5
- data/lib/gooddata/lcm/actions/collect_tagged_objects.rb +1 -1
- data/lib/gooddata/lcm/actions/collect_users_brick_users.rb +10 -4
- data/lib/gooddata/lcm/actions/create_segment_masters.rb +12 -2
- data/lib/gooddata/lcm/actions/ensure_data_product.rb +10 -0
- data/lib/gooddata/lcm/actions/ensure_technical_users_domain.rb +5 -1
- data/lib/gooddata/lcm/actions/ensure_technical_users_project.rb +3 -0
- data/lib/gooddata/lcm/actions/execute_schedules.rb +10 -0
- data/lib/gooddata/lcm/actions/import_object_collections.rb +1 -1
- data/lib/gooddata/lcm/actions/provision_clients.rb +12 -2
- data/lib/gooddata/lcm/actions/purge_clients.rb +2 -0
- data/lib/gooddata/lcm/actions/rename_existing_client_projects.rb +3 -0
- data/lib/gooddata/lcm/actions/synchronize_attribute_drillpaths.rb +4 -1
- data/lib/gooddata/lcm/actions/synchronize_cas.rb +7 -1
- data/lib/gooddata/lcm/actions/synchronize_clients.rb +11 -1
- data/lib/gooddata/lcm/actions/synchronize_color_palette.rb +7 -1
- data/lib/gooddata/lcm/actions/synchronize_etls_in_segment.rb +12 -7
- data/lib/gooddata/lcm/actions/synchronize_label_types.rb +4 -1
- data/lib/gooddata/lcm/actions/synchronize_ldm.rb +18 -7
- data/lib/gooddata/lcm/actions/synchronize_meta.rb +9 -0
- data/lib/gooddata/lcm/actions/synchronize_new_segments.rb +11 -1
- data/lib/gooddata/lcm/actions/synchronize_processes.rb +7 -1
- data/lib/gooddata/lcm/actions/synchronize_schedules.rb +4 -1
- data/lib/gooddata/lcm/actions/synchronize_tag_objects.rb +6 -0
- data/lib/gooddata/lcm/actions/synchronize_user_filters.rb +60 -15
- data/lib/gooddata/lcm/actions/synchronize_user_groups.rb +7 -1
- data/lib/gooddata/lcm/actions/synchronize_users.rb +106 -3
- data/lib/gooddata/lcm/actions/update_release_table.rb +19 -0
- data/lib/gooddata/lcm/helpers/check_helper.rb +21 -6
- data/lib/gooddata/lcm/lcm2.rb +35 -22
- data/lib/gooddata/lcm/types/class/gd_logger.rb +23 -0
- data/lib/gooddata/lcm/types/class/gd_product.rb +23 -0
- data/lib/gooddata/lcm/types/class/gd_project.rb +23 -0
- data/lib/gooddata/lcm/types/class/smart_hash.rb +23 -0
- data/lib/gooddata/lcm/types/complex/segment.rb +1 -1
- data/lib/gooddata/lcm/types/scalar/integer.rb +2 -2
- data/lib/gooddata/lcm/types/special/any.rb +18 -0
- data/lib/gooddata/models/blueprint/dataset_blueprint.rb +1 -1
- data/lib/gooddata/models/blueprint/to_manifest.rb +1 -3
- data/lib/gooddata/models/blueprint/to_wire.rb +2 -1
- data/lib/gooddata/models/from_wire.rb +13 -1
- data/lib/gooddata/models/metadata/folder.rb +22 -0
- data/lib/gooddata/models/metadata/metric.rb +5 -8
- data/lib/gooddata/models/model.rb +1 -1
- data/lib/gooddata/models/process.rb +42 -32
- data/lib/gooddata/models/project.rb +19 -36
- data/lib/gooddata/models/project_creator.rb +3 -1
- data/lib/gooddata/models/project_role.rb +3 -4
- data/lib/gooddata/models/schedule.rb +0 -2
- data/lib/gooddata/models/user_filters/mandatory_user_filter.rb +9 -1
- data/lib/gooddata/models/user_filters/user_filter.rb +1 -2
- data/lib/gooddata/models/user_filters/user_filter_builder.rb +18 -6
- data/lib/gooddata/rest/client.rb +1 -2
- data/lib/gooddata/rest/connection.rb +12 -46
- data/lib/gooddata/rest/phmap.rb +101 -56
- data/lib/gooddata/version.rb +1 -1
- data/rubydev_public.gpg.encrypted +51 -0
- data/rubydev_secret_keys.gpg.encrypted +109 -0
- data/spec/data/user_filters.csv +2 -0
- data/spec/environment/default.rb +2 -2
- data/spec/environment/development.rb +1 -1
- data/spec/environment/staging.rb +2 -3
- data/spec/environment/testing.rb +4 -4
- data/spec/integration/connection_spec.rb +37 -0
- data/spec/integration/core/connection_spec.rb +1 -1
- data/spec/integration/core/logging_spec.rb +8 -6
- data/spec/integration/core/project_spec.rb +1 -1
- data/spec/integration/mandatory_user_filter_spec.rb +53 -0
- data/spec/integration/mixins/id_to_uri_spec.rb +17 -5
- data/spec/integration/models/label_spec.rb +9 -0
- data/spec/integration/models/metric_spec.rb +24 -0
- data/spec/integration/models/process_spec.rb +35 -0
- data/spec/integration/models/project_role_spec.rb +1 -1
- data/spec/integration/models/schedule_spec.rb +0 -8
- data/spec/integration/schedule_spec.rb +4 -6
- data/spec/integration/user_filters_spec.rb +20 -16
- data/spec/integration/user_group_spec.rb +1 -1
- data/spec/integration/vcr_cassettes/GoodData_-_logging/_logger/can_assign_a_custom_logger.yml +2287 -0
- data/spec/integration/vcr_cassettes/GoodData_-_logging/_logger/client_logs_when_given_custom_message.yml +2287 -0
- data/spec/integration/vcr_cassettes/GoodData_-_logging/_logger/has_the_request_id_logged_when_I_passed_it.yml +2287 -0
- data/spec/integration/vcr_cassettes/GoodData_-_logging/_logging_off/Disables_logging.yml +2287 -0
- data/spec/integration/vcr_cassettes/GoodData_-_logging/_logging_on/Enables_logging.yml +2287 -0
- data/spec/integration/vcr_cassettes/GoodData_-_project/_project/Returns_project_assigned.yml +354 -0
- data/spec/integration/vcr_cassettes/GoodData_-_project/_project_/Assigns_nil.yml +299 -0
- data/spec/integration/vcr_cassettes/GoodData_-_project/_project_/Assigns_project_directly.yml +354 -0
- data/spec/integration/vcr_cassettes/GoodData_-_project/_project_/Assigns_project_using_project_ID.yml +354 -0
- data/spec/integration/vcr_cassettes/GoodData_-_project/_project_/Assigns_project_using_project_URL.yml +354 -0
- data/spec/integration/vcr_cassettes/GoodData_-_project/_with_project/Uses_project_specified.yml +354 -0
- data/spec/integration/vcr_cassettes/GoodData_Metric/all.yml +2065 -0
- data/spec/integration/vcr_cassettes/GoodData_Metric/should_be_able_to_update_folders.yml +119 -0
- data/spec/integration/vcr_cassettes/GoodData_Mixin_MdIdToUri/all.yml +9812 -0
- data/spec/integration/vcr_cassettes/GoodData_Mixin_MdIdToUri/should_get_json_containing_correct_id.yml +174 -0
- data/spec/integration/vcr_cassettes/GoodData_Mixin_MdIdToUri/should_return_nil_for_unknown_id.yml +58 -0
- data/spec/integration/vcr_cassettes/GoodData_Mixin_MdIdToUri/should_throw_BadRequest_for_-1.yml +63 -0
- data/spec/integration/vcr_cassettes/GoodData_Rest_Connection/_connect/Connects_using_username_and_password.yml +299 -0
- data/spec/integration/vcr_cassettes/GoodData_Rest_Connection/_disconnect/Connects_using_username_and_password.yml +299 -0
- data/spec/integration/vcr_cassettes/GoodData_Rest_Connection/_generate_request_id/Generates_a_non-empty_string.yml +2287 -0
- data/spec/integration/vcr_cassettes/GoodData_UserGroup/_/Should_list_user_groups_as_Array.yml +56 -0
- data/spec/integration/vcr_cassettes/GoodData_UserGroup/_add_members/Should_add_member.yml +315 -0
- data/spec/integration/vcr_cassettes/GoodData_UserGroup/_members/Should_return_members_as_array.yml +54 -0
- data/spec/integration/vcr_cassettes/GoodData_UserGroup/_remove_members/Should_remove_existing_members.yml +258 -0
- data/spec/integration/vcr_cassettes/GoodData_UserGroup/_save/updates_existing_group.yml +159 -0
- data/spec/integration/vcr_cassettes/GoodData_UserGroup/_set_members/Should_set_new_members.yml +158 -0
- data/spec/integration/vcr_cassettes/GoodData_UserGroup/all.yml +809 -0
- data/spec/spec_helper.rb +46 -2
- data/spec/unit/actions/associate_clients_spec.rb +2 -1
- data/spec/unit/actions/collect_data_product_spec.rb +3 -1
- data/spec/unit/actions/collect_segment_clients_spec.rb +1 -0
- data/spec/unit/actions/create_segment_masters_spec.rb +1 -0
- data/spec/unit/actions/ensure_data_product_spec.rb +1 -0
- data/spec/unit/actions/ensure_technical_users_domain_spec.rb +2 -0
- data/spec/unit/actions/ensure_technical_users_project_spec.rb +4 -0
- data/spec/unit/actions/provision_clients_spec.rb +2 -1
- data/spec/unit/actions/synchronize_etls_in_segment_spec.rb +0 -6
- data/spec/unit/actions/synchronize_ldm_spec.rb +20 -7
- data/spec/unit/actions/synchronize_user_filters_spec.rb +21 -0
- data/spec/unit/helpers/check_helper_production_spec.rb +34 -0
- data/spec/unit/helpers/check_helper_spec.rb +97 -9
- data/spec/unit/lcm/lcm2_spec.rb +67 -3
- data/spec/unit/models/blueprint/to_wire_spec.rb +1 -0
- data/spec/unit/models/dataset_blueprint.rb +14 -0
- data/spec/unit/models/from_wire_spec.rb +20 -0
- data/spec/unit/models/model_spec.rb +10 -0
- data/spec/unit/models/to_manifest_spec.rb +29 -0
- data/spec/unit/models/user_filters/user_filter_builder_spec.rb +44 -6
- data/spec/unit/rest/phmap_spec.rb +117 -0
- data/spec/vcr_configurer.rb +63 -0
- metadata +283 -24
- data/lib/gooddata/lcm/actions/ensure_segments.rb +0 -32
data/spec/spec_helper.rb
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
# Copyright (c) 2010-2017 GoodData Corporation. All rights reserved.
|
4
4
|
# This source code is licensed under the BSD-style license found in the
|
5
5
|
# LICENSE file in the root directory of this source tree.
|
6
|
+
#
|
7
|
+
ENV['RSPEC_ENV'] = 'test'
|
6
8
|
|
7
9
|
require 'simplecov'
|
8
10
|
# for simplecov to work correctly, it has to be started before any other code
|
@@ -26,12 +28,13 @@ require 'pathname'
|
|
26
28
|
require 'webmock/rspec'
|
27
29
|
require 'gooddata'
|
28
30
|
|
31
|
+
vcr_enabled = !ENV['VCR_ON'] || ENV['VCR_ON'] == 'true' # VCR is enabled by default - set VCR_ON=false to disable
|
32
|
+
require 'vcr_configurer' if vcr_enabled
|
33
|
+
|
29
34
|
logger = Logger.new(STDOUT)
|
30
35
|
logger.level = Logger::WARN
|
31
36
|
GoodData.logger = logger
|
32
37
|
|
33
|
-
WebMock.disable!
|
34
|
-
|
35
38
|
# Automagically include all helpers/*_helper.rb
|
36
39
|
|
37
40
|
require_relative 'environment/environment'
|
@@ -63,4 +66,45 @@ RSpec.configure do |config|
|
|
63
66
|
config.filter_run_excluding :broken => true
|
64
67
|
|
65
68
|
config.fail_fast = false
|
69
|
+
|
70
|
+
if vcr_enabled
|
71
|
+
config.before(:all) do
|
72
|
+
# in case the test uses VCR
|
73
|
+
if self.class.metadata[:vcr]
|
74
|
+
# replace parallel iterations with the serial one, since VCR can't handle parallel request matching correctly
|
75
|
+
module Enumerable
|
76
|
+
def peach_with_index(*)
|
77
|
+
each_with_index
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
# insert the cassete recording everything what happens outside the tests cases
|
82
|
+
VCR.insert_cassette("#{self.class.metadata[:description]}/all")
|
83
|
+
|
84
|
+
# avoid polling idle time by overriding sleep
|
85
|
+
module Kernel
|
86
|
+
alias :old_sleep :sleep
|
87
|
+
def sleep(n)
|
88
|
+
n
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
config.after(:all) do
|
95
|
+
# in case the test uses VCR
|
96
|
+
if self.class.metadata[:vcr]
|
97
|
+
# eject the cassete recording everything what happens outside the tests cases
|
98
|
+
VCR.eject_cassette
|
99
|
+
|
100
|
+
# reload the original parallel iterations
|
101
|
+
load('pmap.rb') if self.class.metadata[:vcr]
|
102
|
+
|
103
|
+
# reload sleep method
|
104
|
+
module Kernel
|
105
|
+
alias :sleep :old_sleep
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
66
110
|
end
|
@@ -24,6 +24,7 @@ describe GoodData::LCM2::CollectDataProduct do
|
|
24
24
|
let(:data_product_id) { 'data-product' }
|
25
25
|
let(:params) do
|
26
26
|
params = {
|
27
|
+
domain: domain,
|
27
28
|
gdc_gd_client: client,
|
28
29
|
gdc_logger: gdc_logger,
|
29
30
|
data_product: data_product_id
|
@@ -42,7 +43,8 @@ describe GoodData::LCM2::CollectDataProduct do
|
|
42
43
|
let(:params) do
|
43
44
|
params = {
|
44
45
|
gdc_gd_client: client,
|
45
|
-
gdc_logger: gdc_logger
|
46
|
+
gdc_logger: gdc_logger,
|
47
|
+
domain: domain
|
46
48
|
}
|
47
49
|
GoodData::LCM2.convert_to_smart_hash(params)
|
48
50
|
end
|
@@ -26,6 +26,7 @@ describe GoodData::LCM2::CreateSegmentMasters do
|
|
26
26
|
segments: [{ segment_id: 'segment_foo', driver: 'Pg', master_name: 'name' }],
|
27
27
|
tokens: { pg: 'pgtoken' },
|
28
28
|
ads_client: ads_client,
|
29
|
+
domain: domain,
|
29
30
|
development_client: development_client,
|
30
31
|
gdc_logger: gdc_logger,
|
31
32
|
project_environment: 'DEVELOPMENT',
|
@@ -31,6 +31,7 @@ describe GoodData::LCM2::EnsureTechnicalUsersDomain do
|
|
31
31
|
let(:params) do
|
32
32
|
params = {
|
33
33
|
gdc_gd_client: gdc_gd_client,
|
34
|
+
domain: domain,
|
34
35
|
technical_user: ['foo@bar.com']
|
35
36
|
}
|
36
37
|
GoodData::LCM2.convert_to_smart_hash(params)
|
@@ -42,6 +43,7 @@ describe GoodData::LCM2::EnsureTechnicalUsersDomain do
|
|
42
43
|
let(:params) do
|
43
44
|
params = {
|
44
45
|
gdc_gd_client: gdc_gd_client,
|
46
|
+
domain: domain,
|
45
47
|
technical_users: ['foo@bar.com']
|
46
48
|
}
|
47
49
|
GoodData::LCM2.convert_to_smart_hash(params)
|
@@ -25,6 +25,7 @@ end
|
|
25
25
|
describe GoodData::LCM2::EnsureTechnicalUsersProject do
|
26
26
|
let(:gdc_gd_client) { double(:gdc_gd_client) }
|
27
27
|
let(:project) { double(:project) }
|
28
|
+
let(:domain) { double(:domain) }
|
28
29
|
before do
|
29
30
|
allow(project).to receive(:title) { 'foo project' }
|
30
31
|
allow(project).to receive(:pid) { 'abcdefg' }
|
@@ -38,6 +39,7 @@ describe GoodData::LCM2::EnsureTechnicalUsersProject do
|
|
38
39
|
gdc_gd_client: gdc_gd_client,
|
39
40
|
technical_users: ['foo@bar.com'],
|
40
41
|
synchronize: [],
|
42
|
+
domain: domain,
|
41
43
|
clients: [{ project: 'abcdefg' }]
|
42
44
|
}
|
43
45
|
GoodData::LCM2.convert_to_smart_hash(params)
|
@@ -51,6 +53,7 @@ describe GoodData::LCM2::EnsureTechnicalUsersProject do
|
|
51
53
|
params = {
|
52
54
|
gdc_gd_client: gdc_gd_client,
|
53
55
|
technical_user: ['foo@bar.com'],
|
56
|
+
domain: domain,
|
54
57
|
synchronize: [{ to: [{ pid: 'qux' }] }]
|
55
58
|
}
|
56
59
|
GoodData::LCM2.convert_to_smart_hash(params)
|
@@ -62,6 +65,7 @@ describe GoodData::LCM2::EnsureTechnicalUsersProject do
|
|
62
65
|
let(:params) do
|
63
66
|
params = {
|
64
67
|
gdc_gd_client: gdc_gd_client,
|
68
|
+
domain: domain,
|
65
69
|
technical_users: ['foo@bar.com'],
|
66
70
|
synchronize: [{ to: [{ pid: 'qux' }] }]
|
67
71
|
}
|
@@ -32,12 +32,13 @@ describe GoodData::LCM2::ProvisionClients do
|
|
32
32
|
segments: [
|
33
33
|
segment
|
34
34
|
],
|
35
|
+
domain: domain,
|
35
36
|
data_product: data_product
|
36
37
|
}
|
37
38
|
GoodData::LCM2.convert_to_smart_hash(params)
|
38
39
|
end
|
39
40
|
|
40
|
-
it 'clean all zombie clients
|
41
|
+
it 'clean all zombie clients' do
|
41
42
|
expect(GoodData::LCM2::PurgeClients).to receive(:call).and_return(results: [], params: { client_projects: [] })
|
42
43
|
expect { subject.class.call(params) }.to raise_error('limit reached')
|
43
44
|
end
|
@@ -125,9 +125,7 @@ describe GoodData::LCM2::SynchronizeETLsInSegment do
|
|
125
125
|
end
|
126
126
|
|
127
127
|
it 'each schedules must have different parameters' do
|
128
|
-
schedule1.should_receive(:update_params).once.ordered.with(CLIENT_ID: 'foo', GOODOT_CUSTOM_PROJECT_ID: 'foo')
|
129
128
|
schedule1.should_receive(:update_params).once.ordered.with('HELLO' => 'hi')
|
130
|
-
schedule2.should_receive(:update_params).once.ordered.with(CLIENT_ID: 'foo', GOODOT_CUSTOM_PROJECT_ID: 'foo')
|
131
129
|
schedule2.should_receive(:update_params).once.ordered.with('BYE' => 'bye')
|
132
130
|
subject.class.call(params)
|
133
131
|
end
|
@@ -161,9 +159,7 @@ describe GoodData::LCM2::SynchronizeETLsInSegment do
|
|
161
159
|
end
|
162
160
|
|
163
161
|
it 'all schedules must have the parameter' do
|
164
|
-
schedule1.should_receive(:update_params).once.ordered.with(CLIENT_ID: 'foo', GOODOT_CUSTOM_PROJECT_ID: 'foo')
|
165
162
|
schedule1.should_receive(:update_params).once.ordered.with('HELLO' => 'hi')
|
166
|
-
schedule2.should_receive(:update_params).once.ordered.with(CLIENT_ID: 'foo', GOODOT_CUSTOM_PROJECT_ID: 'foo')
|
167
163
|
schedule2.should_receive(:update_params).once.ordered.with('HELLO' => 'hi')
|
168
164
|
subject.class.call(params)
|
169
165
|
end
|
@@ -202,9 +198,7 @@ describe GoodData::LCM2::SynchronizeETLsInSegment do
|
|
202
198
|
end
|
203
199
|
|
204
200
|
it 'parameters should be passed to the correct client project and schedule' do
|
205
|
-
schedule1.should_receive(:update_params).once.ordered.with(CLIENT_ID: 'foo', GOODOT_CUSTOM_PROJECT_ID: 'foo')
|
206
201
|
schedule1.should_receive(:update_params).once.ordered.with('HELLO' => 'hi')
|
207
|
-
schedule2.should_receive(:update_params).once.ordered.with(CLIENT_ID: 'foo', GOODOT_CUSTOM_PROJECT_ID: 'foo')
|
208
202
|
subject.class.call(params)
|
209
203
|
end
|
210
204
|
end
|
@@ -15,8 +15,9 @@ describe GoodData::LCM2::SynchronizeLdm do
|
|
15
15
|
let(:gdc_gd_client) { double(GoodData::Rest::Client) }
|
16
16
|
let(:logger) { double(Logger) }
|
17
17
|
let(:project) { double(GoodData::Project) }
|
18
|
+
let(:target_project) { double(GoodData::Project) }
|
18
19
|
let(:synchronize) do
|
19
|
-
[{ from: '
|
20
|
+
[{ from: 'from_pid', to: [{ pid: 'to_pid' }] }]
|
20
21
|
end
|
21
22
|
let(:basic_params) do
|
22
23
|
{
|
@@ -31,15 +32,18 @@ describe GoodData::LCM2::SynchronizeLdm do
|
|
31
32
|
end
|
32
33
|
|
33
34
|
before do
|
34
|
-
allow(gdc_gd_client).to receive(:projects)
|
35
|
+
allow(gdc_gd_client).to receive(:projects)
|
36
|
+
.with('from_pid')
|
37
|
+
.and_return(project)
|
38
|
+
allow(gdc_gd_client).to receive(:projects)
|
39
|
+
.with('to_pid')
|
40
|
+
.and_return(target_project)
|
35
41
|
allow(project).to receive(:title)
|
36
42
|
allow(project).to receive(:pid)
|
43
|
+
allow(project).to receive(:blueprint)
|
37
44
|
allow(logger).to receive(:info)
|
38
|
-
|
39
|
-
|
40
|
-
context 'when include_computed_attributes is not specified' do
|
41
|
-
let(:params) { basic_params }
|
42
|
-
it_behaves_like 'a computed attributes synchronizer'
|
45
|
+
allow(target_project).to receive(:title)
|
46
|
+
allow(target_project).to receive(:update_from_blueprint)
|
43
47
|
end
|
44
48
|
|
45
49
|
context 'when include_computed_attributes is true' do
|
@@ -54,4 +58,13 @@ describe GoodData::LCM2::SynchronizeLdm do
|
|
54
58
|
subject.class.call(converted_params)
|
55
59
|
end
|
56
60
|
end
|
61
|
+
|
62
|
+
context 'when exclude_fact_rule is true' do
|
63
|
+
let(:params) { basic_params.merge(exclude_fact_rule: 'true') }
|
64
|
+
it 'calls update_from_blueprint with exclude_fact_rule option' do
|
65
|
+
expect(target_project).to receive(:update_from_blueprint)
|
66
|
+
.with(any_args, hash_including(exclude_fact_rule: true))
|
67
|
+
subject.class.call(converted_params)
|
68
|
+
end
|
69
|
+
end
|
57
70
|
end
|
@@ -85,6 +85,27 @@ describe GoodData::LCM2::SynchronizeUserFilters do
|
|
85
85
|
it_behaves_like 'a user action filtering segments' do
|
86
86
|
let(:message_for_project) { :add_data_permissions }
|
87
87
|
end
|
88
|
+
|
89
|
+
context 'when dry_run param is true' do
|
90
|
+
let(:params) do
|
91
|
+
params = {
|
92
|
+
GDC_GD_CLIENT: client,
|
93
|
+
input_source: 'foo',
|
94
|
+
domain: 'bar',
|
95
|
+
filters_config: { labels: [] },
|
96
|
+
sync_mode: mode,
|
97
|
+
gdc_logger: logger,
|
98
|
+
dry_run: true
|
99
|
+
}
|
100
|
+
GoodData::LCM2.convert_to_smart_hash(params)
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'sets the dry_run option' do
|
104
|
+
expect(project).to receive(:add_data_permissions)
|
105
|
+
.with(instance_of(Array), hash_including(dry_run: true))
|
106
|
+
subject.class.call(params)
|
107
|
+
end
|
108
|
+
end
|
88
109
|
end
|
89
110
|
end
|
90
111
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'gooddata/lcm/actions/base_action'
|
2
|
+
require 'gooddata/lcm/helpers/check_helper'
|
3
|
+
require 'gooddata/lcm/types/types'
|
4
|
+
|
5
|
+
describe 'GoodData::LCM2::Helpers::Check' do
|
6
|
+
let(:params) do
|
7
|
+
params = { test_param_three: 'Testing param three' }
|
8
|
+
GoodData::LCM2.convert_to_smart_hash(params)
|
9
|
+
end
|
10
|
+
let(:spec) do
|
11
|
+
GoodData::LCM2::BaseAction.define_params(self) do
|
12
|
+
description 'Testing param two'
|
13
|
+
param :test_param_two, instance_of(GoodData::LCM2::Type::StringType), required: true
|
14
|
+
|
15
|
+
description 'Testing param four'
|
16
|
+
param :test_param_three, instance_of(GoodData::LCM2::Type::IntegerType), required: false
|
17
|
+
end
|
18
|
+
end
|
19
|
+
context 'when running outside the tests' do
|
20
|
+
let(:mocked_logger) { double(Logger) }
|
21
|
+
before do
|
22
|
+
expect(GoodData).to receive(:logger).and_return(mocked_logger)
|
23
|
+
expect(ENV).to receive(:[]).with('RSPEC_ENV').and_return('production')
|
24
|
+
expect(mocked_logger).to receive(:error)
|
25
|
+
end
|
26
|
+
it 'writes out error message but do not fail when virifying required params' do
|
27
|
+
expect { GoodData::LCM2::Helpers.check_params(spec, params) }.not_to raise_error(/Mandatory/)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'writes out error message but do not fail when checking types' do
|
31
|
+
expect { GoodData::LCM2::Helpers.check_params(spec, params) }.not_to raise_error(/has invalid type/)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -7,21 +7,27 @@ require 'gooddata/lcm/actions/base_action'
|
|
7
7
|
require 'gooddata/lcm/helpers/check_helper'
|
8
8
|
require 'gooddata/lcm/types/types'
|
9
9
|
|
10
|
-
describe 'GoodData::LCM2::Helpers::
|
10
|
+
describe 'GoodData::LCM2::Helpers::Check' do
|
11
11
|
let(:params) do
|
12
12
|
params = {
|
13
13
|
test_param_two: 'Testing param two',
|
14
14
|
test_param_three: 'Testing param three',
|
15
|
-
test_param_four: 4
|
15
|
+
test_param_four: 4,
|
16
|
+
UPPER_case_param: 'qux'
|
16
17
|
}
|
17
18
|
GoodData::LCM2.convert_to_smart_hash(params)
|
18
19
|
end
|
19
|
-
|
20
|
-
|
20
|
+
let(:spec) do
|
21
|
+
GoodData::LCM2::BaseAction.define_params(self) do
|
21
22
|
description 'Testing param one'
|
22
23
|
param :test_param_one, instance_of(GoodData::LCM2::Type::StringType), required: true
|
24
|
+
|
25
|
+
description 'Param four'
|
26
|
+
param :test_param_four, instance_of(GoodData::LCM2::Type::StringType), required: false
|
23
27
|
end
|
24
|
-
|
28
|
+
end
|
29
|
+
it 'verifies required' do
|
30
|
+
expect { GoodData::LCM2::Helpers.check_params(spec, params) }.to raise_error(/Mandatory/)
|
25
31
|
end
|
26
32
|
|
27
33
|
it 'fills default' do
|
@@ -37,10 +43,92 @@ describe 'GoodData::LCM2::Helpers::Checkout' do
|
|
37
43
|
end
|
38
44
|
|
39
45
|
it 'checks types' do
|
40
|
-
|
41
|
-
|
42
|
-
|
46
|
+
params['test_param_one'] = 'test_param_one'
|
47
|
+
expect { GoodData::LCM2::Helpers.check_params(spec, params) }.to raise_error(/has invalid type/)
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'fails when unspecified variable is acessed' do
|
51
|
+
params.setup_filters(spec)
|
52
|
+
expect { params[:test_param_three] }.to raise_error(/not defined in the specification/)
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'when created from stringified hash' do
|
56
|
+
subject { GoodData::LCM2::Helpers.check_params(spec, params) }
|
57
|
+
let(:params) do
|
58
|
+
raw_params = { 'update_preference' => { 'keep_data' => false,
|
59
|
+
'allow_cascade_drops' => true } }
|
60
|
+
GoodData::LCM2.convert_to_smart_hash(raw_params)
|
61
|
+
end
|
62
|
+
|
63
|
+
let(:spec) do
|
64
|
+
GoodData::LCM2::BaseAction.define_params(self) do
|
65
|
+
description 'Some param'
|
66
|
+
param :update_preference, instance_of(GoodData::LCM2::Type::UpdatePreferenceType), required: false
|
67
|
+
|
68
|
+
description 'Replacement param'
|
69
|
+
param :replacement_param, instance_of(GoodData::LCM2::Type::GdClientType), required: false
|
70
|
+
|
71
|
+
description 'Deprecated param'
|
72
|
+
param :deprecated_param, instance_of(GoodData::LCM2::Type::StringType), required: false, deprecated: true, replacement: :replacement_param
|
73
|
+
|
74
|
+
description 'List of production tag Names'
|
75
|
+
param :production_tags, array_of(instance_of(GoodData::LCM2::Type::StringType)), required: false
|
76
|
+
|
77
|
+
description 'Production Tag Names'
|
78
|
+
param :production_tag, instance_of(GoodData::LCM2::Type::StringType), required: false, deprecated: true, replacement: :production_tags
|
79
|
+
|
80
|
+
description 'Default testing param'
|
81
|
+
param :default_test, array_of(instance_of(GoodData::LCM2::Type::StringType)), required: false, default: 'default value'
|
82
|
+
|
83
|
+
description 'Deprecated testing param'
|
84
|
+
param :deprecated_test, instance_of(GoodData::LCM2::Type::StringType), required: false, deprecated: true, replacement: :default_test
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'works with default values' do
|
89
|
+
subject
|
90
|
+
expect(params[:update_preference][:keep_data]).to be(false)
|
91
|
+
end
|
92
|
+
|
93
|
+
context 'when deprecated params together with default values are supplied' do
|
94
|
+
let(:params) do
|
95
|
+
raw_params = {
|
96
|
+
'deprecated_param' => 'franta',
|
97
|
+
'production_tag' => 'pepa',
|
98
|
+
'update_preference' => {
|
99
|
+
'cascade_drops' => true,
|
100
|
+
'keep_data' => false
|
101
|
+
},
|
102
|
+
'deprecated_test' => 'jednicka'
|
103
|
+
}
|
104
|
+
GoodData::LCM2.convert_to_smart_hash(raw_params)
|
105
|
+
end
|
106
|
+
it 'works with default values on deprecated params' do
|
107
|
+
subject
|
108
|
+
expect(params[:update_preference][:keep_data]).to be(false)
|
109
|
+
expect(params[:update_preference][:cascade_drops]).to be(true)
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'does not fill default values on replacement params if deprecated one has value' do
|
113
|
+
subject
|
114
|
+
expect(params[:default_test]).to be(nil)
|
115
|
+
expect(params[:deprecated_test]).to eq('jednicka')
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
context 'when key contains upper-case letters' do
|
121
|
+
let(:spec) do
|
122
|
+
GoodData::LCM2::BaseAction.define_params(self) do
|
123
|
+
description 'Testing param'
|
124
|
+
param :upper_case_param, instance_of(GoodData::LCM2::Type::StringType)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
before { params.setup_filters(spec) }
|
129
|
+
|
130
|
+
it 'fetching works with both lower case and original case' do
|
131
|
+
['upper_case_param', :upper_case_param, 'UPPER_case_param', :UPPER_case_param].map { |e| expect(params[e]).to eq('qux') }
|
43
132
|
end
|
44
|
-
expect { GoodData::LCM2::Helpers.check_params(PARAMS_3, params) }.to raise_error(/has invalid type/)
|
45
133
|
end
|
46
134
|
end
|