-
Notifications
You must be signed in to change notification settings - Fork 124
/
Copy pathpartial_md_export_import_spec.rb
41 lines (31 loc) · 1.64 KB
/
partial_md_export_import_spec.rb
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
# encoding: UTF-8
#
# Copyright (c) 2010-2017 GoodData Corporation. All rights reserved.
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
require 'gooddata'
describe "Object export between projects", :vcr, :constraint => 'slow' do
before(:all) do
@client = ConnectionHelper.create_default_connection
spec = MultiJson.load(File.read("./spec/data/blueprints/test_project_model_spec.json"), :symbolize_keys => true)
@source_project = @client.create_project_from_blueprint(spec, token: ConnectionHelper::SECRETS[:gd_project_token], environment: ProjectHelper::ENVIRONMENT)
@target_project = @client.create_project_from_blueprint(spec, token: ConnectionHelper::SECRETS[:gd_project_token], environment: ProjectHelper::ENVIRONMENT)
end
after(:all) do
@source_project.delete unless @source_project.nil?
@target_project.delete unless @target_project.nil?
@client.disconnect
end
it "should transfer a metric" do
f = GoodData::Fact.find_first_by_title('Lines Changed', :client => @client, :project => @source_project)
metric_title = "Testing metric to be exported"
metric = @source_project.create_metric("SELECT SUM(#\"#{f.title}\")", :title => metric_title)
metric.save
expect(@target_project.metrics.count).to eq 0
@source_project.partial_md_export(metric, :project => @target_project)
expect(@target_project.metrics.count).to eq 1
metric = GoodData::Metric.find_first_by_title(metric_title, :client => @client, :project => @target_project)
expect(metric).not_to be_nil
expect(metric.title).to eq metric_title
end
end