-
Notifications
You must be signed in to change notification settings - Fork 125
Expand file tree
/
Copy pathblueprint_upgrade_spec.rb
More file actions
113 lines (95 loc) · 4.31 KB
/
blueprint_upgrade_spec.rb
File metadata and controls
113 lines (95 loc) · 4.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# (C) 2019-2020 GoodData Corporation
require 'gooddata'
describe 'Should upgrade custom v2 for project', :vcr, :constraint => 'slow' do
before(:all) do
@client = ConnectionHelper.create_default_connection
@blueprint = GoodData::Model::ProjectBlueprint.from_json('./spec/data/blueprints/old_date_dimension.json')
end
after(:all) do
@client&.disconnect
end
it 'upgrade all date dimension to custom v2' do
to_project = @client&.create_project_from_blueprint(@blueprint, auth_token: ConnectionHelper::SECRETS[:gd_project_token], environment: ProjectHelper::ENVIRONMENT)
blueprint = to_project.blueprint(include_ca: true)
date_old = GoodData::Model::ProjectBlueprint.date_dimensions(blueprint)
expect(date_old).not_to be_nil
date_old.each do |date|
expect(%w[datecustom dategooddata].any? { |e| date[:id] == e }).to be_truthy
expect(GoodData::LCM2::MigrateGdcDateDimension::DATE_DIMENSION_OLD.any? { |e| date[:urn]&.include?(e) }).to be_truthy
end
message = get_upgrade_message(true, nil)
to_project&.upgrade_custom_v2(message)
blueprint = to_project.blueprint(include_ca: true)
date_new = GoodData::Model::ProjectBlueprint.date_dimensions(blueprint)
expect(date_new).not_to be_nil
date_new.each do |date|
expect(%w[datecustom dategooddata].any? { |e| date[:id] == e }).to be_truthy
expect(date[:urn]&.include?(GoodData::LCM2::MigrateGdcDateDimension::DATE_DIMENSION_CUSTOM_V2)).to be_truthy
end
to_project&.delete
end
it 'upgrade a date dimension to custom v2' do
to_project = @client&.create_project_from_blueprint(@blueprint, auth_token: ConnectionHelper::SECRETS[:gd_project_token], environment: ProjectHelper::ENVIRONMENT)
blueprint = to_project.blueprint(include_ca: true)
date_old = GoodData::Model::ProjectBlueprint.date_dimensions(blueprint)
expect(date_old).not_to be_nil
date_old.each do |date|
expect(%w[datecustom dategooddata].any? { |e| date[:id] == e }).to be_truthy
expect(GoodData::LCM2::MigrateGdcDateDimension::DATE_DIMENSION_OLD.any? { |e| date[:urn]&.include?(e) }).to be_truthy
end
message = get_upgrade_message(false, ['datecustom.dataset.dt'])
to_project&.upgrade_custom_v2(message)
blueprint = to_project.blueprint(include_ca: true)
date_new = GoodData::Model::ProjectBlueprint.date_dimensions(blueprint)
expect(date_new).not_to be_nil
date_new.each do |date|
expect(%w[datecustom dategooddata].any? { |e| date[:id] == e }).to be_truthy
if date[:id] == 'datecustom'
expect(date[:urn]&.include?(GoodData::LCM2::MigrateGdcDateDimension::DATE_DIMENSION_CUSTOM_V2)).to be_truthy
else
expect(date[:urn]&.include?('gooddata')).to be_truthy
end
end
to_project&.delete
end
it 'upgrade multiple date dimension to custom v2' do
to_project = @client&.create_project_from_blueprint(@blueprint, auth_token: ConnectionHelper::SECRETS[:gd_project_token], environment: ProjectHelper::ENVIRONMENT)
blueprint = to_project.blueprint(include_ca: true)
date_old = GoodData::Model::ProjectBlueprint.date_dimensions(blueprint)
expect(date_old).not_to be_nil
date_old.each do |date|
expect(%w[datecustom dategooddata].any? { |e| date[:id] == e }).to be_truthy
expect(GoodData::LCM2::MigrateGdcDateDimension::DATE_DIMENSION_OLD.any? { |e| date[:urn]&.include?(e) }).to be_truthy
end
message = get_upgrade_message(false, ['datecustom.dataset.dt','dategooddata.dataset.dt'])
to_project&.upgrade_custom_v2(message)
blueprint = to_project.blueprint(include_ca: true)
date_new = GoodData::Model::ProjectBlueprint.date_dimensions(blueprint)
expect(date_new).not_to be_nil
date_new.each do |date|
expect(%w[datecustom dategooddata].any? { |e| date[:id] == e }).to be_truthy
expect(date[:urn]&.include?(GoodData::LCM2::MigrateGdcDateDimension::DATE_DIMENSION_CUSTOM_V2)).to be_truthy
end
to_project&.delete
end
def get_upgrade_message(is_all, upgrade_datasets)
if is_all
{
upgrade: {
dateDatasets: {
upgrade: "all"
}
}
}
else
{
upgrade: {
dateDatasets: {
upgrade: "exact",
datasets: upgrade_datasets
}
}
}
end
end
end