Skip to content

Commit c4c7766

Browse files
committed
[NEP-18090]: Adding a class for warming up the dataset cache
Adjusting indentation.
1 parent 0246deb commit c4c7766

File tree

1 file changed

+35
-35
lines changed

1 file changed

+35
-35
lines changed

spec/superset/dataset/warm_up_cache_spec.rb

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,51 +6,51 @@
66

77
describe '.perform' do
88
context "Dataset count is not considered" do
9-
let(:response) { nil }
10-
before do
11-
allow(subject).to receive(:response).and_return(response)
9+
let(:response) { nil }
10+
before do
11+
allow(subject).to receive(:response).and_return(response)
12+
end
13+
context 'when dashboard_id is not present' do
14+
let(:dashboard_id) { nil }
15+
16+
it 'raises an error' do
17+
expect { subject.perform }.to raise_error(Superset::Request::InvalidParameterError, "dashboard_id must be present and must be an integer")
1218
end
13-
context 'when dashboard_id is not present' do
14-
let(:dashboard_id) { nil }
19+
end
1520

16-
it 'raises an error' do
17-
expect { subject.perform }.to raise_error(Superset::Request::InvalidParameterError, "dashboard_id must be present and must be an integer")
18-
end
19-
end
20-
21-
context 'when dashboard_id is not an integer' do
22-
let(:dashboard_id) { 'string' }
21+
context 'when dashboard_id is not an integer' do
22+
let(:dashboard_id) { 'string' }
2323

24-
it 'raises an error' do
25-
expect { subject.perform }.to raise_error(Superset::Request::InvalidParameterError, "dashboard_id must be present and must be an integer")
26-
end
24+
it 'raises an error' do
25+
expect { subject.perform }.to raise_error(Superset::Request::InvalidParameterError, "dashboard_id must be present and must be an integer")
2726
end
27+
end
2828

29-
context 'when dashboard_id is an integer' do
30-
let(:response) { 'Dashboard warmed up' }
29+
context 'when dashboard_id is an integer' do
30+
let(:response) { 'Dashboard warmed up' }
3131

32-
it 'warms up the dashboard' do
33-
expect(subject.perform).to eq response
34-
end
32+
it 'warms up the dashboard' do
33+
expect(subject.perform).to eq response
3534
end
35+
end
3636
end
3737

3838
context 'when dashboard has multiple datasets' do
39-
let(:dataset_details) do
40-
[
41-
{"name"=>"client database 1", "datasource_name"=>"datasource 101"},
42-
{"name"=>"client database 2", "datasource_name"=>"datasource 102"},
43-
]
44-
end
45-
let(:api_response) { "Dataset warmed up" }
46-
before do
47-
allow(subject).to receive(:fetch_dataset_details).with(dashboard_id) { dataset_details }
48-
allow(subject).to receive(:api_response).and_return(api_response)
49-
end
50-
it 'warms up all the datasets' do
51-
subject.response
52-
expect(subject).to have_received(:api_response).exactly(dataset_details.count).times
53-
end
39+
let(:dataset_details) do
40+
[
41+
{"name"=>"client database 1", "datasource_name"=>"datasource 101"},
42+
{"name"=>"client database 2", "datasource_name"=>"datasource 102"},
43+
]
44+
end
45+
let(:api_response) { "Dataset warmed up" }
46+
before do
47+
allow(subject).to receive(:fetch_dataset_details).with(dashboard_id) { dataset_details }
48+
allow(subject).to receive(:api_response).and_return(api_response)
49+
end
50+
it 'warms up all the datasets' do
51+
subject.response
52+
expect(subject).to have_received(:api_response).exactly(dataset_details.count).times
53+
end
5454
end
5555
end
5656
end

0 commit comments

Comments
 (0)